Package policysimulator is an auto-generated package for the Policy Simulator API.
Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay. A Replay is a type of simulation that lets you see how your members’ access to resources might change if you changed your IAM policy. During a Replay, Policy Simulator re-evaluates, or replays, past access attempts under both the current policy and your proposed policy, and compares those results to determine how your members’ access might change under the proposed policy.
General documentation
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview . Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/policysimulator/apiv1@latest ctx := context . Background () // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c , err := policysimulator . NewOrgPolicyViolationsPreviewClient ( ctx ) if err != nil { // TODO: Handle error. } defer c . Close ()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client, mentioned above.
req := & policysimulatorpb . CreateOrgPolicyViolationsPreviewRequest { // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#CreateOrgPolicyViolationsPreviewRequest. } op , err := c . CreateOrgPolicyViolationsPreview ( ctx , req ) if err != nil { // TODO: Handle error. } resp , err := op . Wait ( ctx ) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewOrgPolicyViolationsPreviewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
  func 
  
 DefaultAuthScopes 
 () 
  
 [] 
  string 
 
 
 
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
CreateOrgPolicyViolationsPreviewOperation
  type 
  
 CreateOrgPolicyViolationsPreviewOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 
 
CreateOrgPolicyViolationsPreviewOperation manages a long-running operation from CreateOrgPolicyViolationsPreview.
func (*CreateOrgPolicyViolationsPreviewOperation) Done
  func 
  
 ( 
 op 
  
 * 
  CreateOrgPolicyViolationsPreviewOperation 
 
 ) 
  
 Done 
 () 
  
  bool 
 
 
 
Done reports whether the long-running operation has completed.
func (*CreateOrgPolicyViolationsPreviewOperation) Metadata
  func 
  
 ( 
 op 
  
 * 
  CreateOrgPolicyViolationsPreviewOperation 
 
 ) 
  
 Metadata 
 () 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  CreateOrgPolicyViolationsPreviewOperationMetadata 
 
 , 
  
  error 
 
 ) 
 
 
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*CreateOrgPolicyViolationsPreviewOperation) Name
  func 
  
 ( 
 op 
  
 * 
  CreateOrgPolicyViolationsPreviewOperation 
 
 ) 
  
 Name 
 () 
  
  string 
 
 
 
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateOrgPolicyViolationsPreviewOperation) Poll
  func 
  
 ( 
 op 
  
 * 
  CreateOrgPolicyViolationsPreviewOperation 
 
 ) 
  
 Poll 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  OrgPolicyViolationsPreview 
 
 , 
  
  error 
 
 ) 
 
 
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*CreateOrgPolicyViolationsPreviewOperation) Wait
  func 
  
 ( 
 op 
  
 * 
  CreateOrgPolicyViolationsPreviewOperation 
 
 ) 
  
 Wait 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  OrgPolicyViolationsPreview 
 
 , 
  
  error 
 
 ) 
 
 
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
CreateReplayOperation
  type 
  
 CreateReplayOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 
 
CreateReplayOperation manages a long-running operation from CreateReplay.
func (*CreateReplayOperation) Done
  func 
  
 ( 
 op 
  
 * 
  CreateReplayOperation 
 
 ) 
  
 Done 
 () 
  
  bool 
 
 
 
Done reports whether the long-running operation has completed.
func (*CreateReplayOperation) Metadata
  func 
  
 ( 
 op 
  
 * 
  CreateReplayOperation 
 
 ) 
  
 Metadata 
 () 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  ReplayOperationMetadata 
 
 , 
  
  error 
 
 ) 
 
 
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*CreateReplayOperation) Name
  func 
  
 ( 
 op 
  
 * 
  CreateReplayOperation 
 
 ) 
  
 Name 
 () 
  
  string 
 
 
 
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateReplayOperation) Poll
  func 
  
 ( 
 op 
  
 * 
  CreateReplayOperation 
 
 ) 
  
 Poll 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  Replay 
 
 , 
  
  error 
 
 ) 
 
 
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*CreateReplayOperation) Wait
  func 
  
 ( 
 op 
  
 * 
  CreateReplayOperation 
 
 ) 
  
 Wait 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  Replay 
 
 , 
  
  error 
 
 ) 
 
 
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
OperationIterator
  type 
  
 OperationIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  longrunningpb 
 
 . 
  Operation 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 
 
OperationIterator manages a stream of *longrunningpb.Operation.
func (*OperationIterator) All
  func 
  
 ( 
 it 
  
 * 
  OperationIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 longrunningpb 
 . 
 Operation 
 , 
  
 error 
 ] 
 
 
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*OperationIterator) Next
  func 
  
 ( 
 it 
  
 * 
  OperationIterator 
 
 ) 
  
 Next 
 () 
  
 ( 
 * 
  longrunningpb 
 
 . 
  Operation 
 
 , 
  
  error 
 
 ) 
 
 
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*OperationIterator) PageInfo
  func 
  
 ( 
 it 
  
 * 
  OperationIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 
 
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
OrgPolicyViolationIterator
  type 
  
 OrgPolicyViolationIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  policysimulatorpb 
 
 . 
  OrgPolicyViolation 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 
 
OrgPolicyViolationIterator manages a stream of *policysimulatorpb.OrgPolicyViolation.
func (*OrgPolicyViolationIterator) All
  func 
  
 ( 
 it 
  
 * 
  OrgPolicyViolationIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 policysimulatorpb 
 . 
 OrgPolicyViolation 
 , 
  
 error 
 ] 
 
 
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*OrgPolicyViolationIterator) Next
  func 
  
 ( 
 it 
  
 * 
  OrgPolicyViolationIterator 
 
 ) 
  
 Next 
 () 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  OrgPolicyViolation 
 
 , 
  
  error 
 
 ) 
 
 
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*OrgPolicyViolationIterator) PageInfo
  func 
  
 ( 
 it 
  
 * 
  OrgPolicyViolationIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 
 
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
OrgPolicyViolationsPreviewCallOptions
  type 
  
 OrgPolicyViolationsPreviewCallOptions 
  
 struct 
  
 { 
  
 ListOrgPolicyViolationsPreviews 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetOrgPolicyViolationsPreview 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CreateOrgPolicyViolationsPreview 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListOrgPolicyViolations 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetOperation 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListOperations 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 
 
OrgPolicyViolationsPreviewCallOptions contains the retry settings for each method of OrgPolicyViolationsPreviewClient.
OrgPolicyViolationsPreviewClient
  type 
  
 OrgPolicyViolationsPreviewClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  OrgPolicyViolationsPreviewCallOptions 
 
  
 // LROClient is used internally to handle long-running operations. 
  
 // It is exposed so that its CallOptions can be modified if required. 
  
 // Users should not Close this client. 
  
 LROClient 
  
 * 
  lroauto 
 
 . 
  OperationsClient 
 
  
 // contains filtered or unexported fields 
 } 
 
 
OrgPolicyViolationsPreviewClient is a client for interacting with Policy Simulator API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Violations Preview API service for OrgPolicy.
An OrgPolicyViolationsPreview is a preview of the violations that will exist as soon as a proposed OrgPolicy change is submitted. To create an OrgPolicyViolationsPreview, the API user specifies the changes they wish to make and requests the generation of a preview via GenerateViolationsPreview. the OrgPolicy Simulator service then scans the API user’s currently existing resources to determine these resources violate the newly set OrgPolicy.
func NewOrgPolicyViolationsPreviewClient
  func 
  
 NewOrgPolicyViolationsPreviewClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  OrgPolicyViolationsPreviewClient 
 
 , 
  
  error 
 
 ) 
 
 
NewOrgPolicyViolationsPreviewClient creates a new org policy violations preview service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Violations Preview API service for OrgPolicy.
An OrgPolicyViolationsPreview is a preview of the violations that will exist as soon as a proposed OrgPolicy change is submitted. To create an OrgPolicyViolationsPreview, the API user specifies the changes they wish to make and requests the generation of a preview via GenerateViolationsPreview. the OrgPolicy Simulator service then scans the API user’s currently existing resources to determine these resources violate the newly set OrgPolicy.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 
 
func NewOrgPolicyViolationsPreviewRESTClient
  func 
  
 NewOrgPolicyViolationsPreviewRESTClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  OrgPolicyViolationsPreviewClient 
 
 , 
  
  error 
 
 ) 
 
 
NewOrgPolicyViolationsPreviewRESTClient creates a new org policy violations preview service rest client.
Violations Preview API service for OrgPolicy.
An OrgPolicyViolationsPreview is a preview of the violations that will exist as soon as a proposed OrgPolicy change is submitted. To create an OrgPolicyViolationsPreview, the API user specifies the changes they wish to make and requests the generation of a preview via GenerateViolationsPreview. the OrgPolicy Simulator service then scans the API user’s currently existing resources to determine these resources violate the newly set OrgPolicy.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewRESTClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 
 
func (*OrgPolicyViolationsPreviewClient) Close
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 
 
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*OrgPolicyViolationsPreviewClient) Connection (deprecated)
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 Connection 
 () 
  
 * 
 grpc 
 . 
 ClientConn 
 
 
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*OrgPolicyViolationsPreviewClient) CreateOrgPolicyViolationsPreview
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 CreateOrgPolicyViolationsPreview 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  policysimulatorpb 
 
 . 
  CreateOrgPolicyViolationsPreviewRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  CreateOrgPolicyViolationsPreviewOperation 
 
 , 
  
  error 
 
 ) 
 
 
CreateOrgPolicyViolationsPreview createOrgPolicyViolationsPreview creates an OrgPolicyViolationsPreview for the proposed changes in the provided OrgPolicyViolationsPreview.OrgPolicyOverlay. The changes to OrgPolicy are specified by this OrgPolicyOverlay. The resources to scan are inferred from these specified changes.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 CreateOrgPolicyViolationsPreviewRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#CreateOrgPolicyViolationsPreviewRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateOrgPolicyViolationsPreview 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
 
func (*OrgPolicyViolationsPreviewClient) CreateOrgPolicyViolationsPreviewOperation
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 CreateOrgPolicyViolationsPreviewOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  CreateOrgPolicyViolationsPreviewOperation 
 
 
 
CreateOrgPolicyViolationsPreviewOperation returns a new CreateOrgPolicyViolationsPreviewOperation from a given name. The name must be that of a previously created CreateOrgPolicyViolationsPreviewOperation, possibly from a different process.
func (*OrgPolicyViolationsPreviewClient) GetOperation
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 GetOperation 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  longrunningpb 
 
 . 
  GetOperationRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  longrunningpb 
 
 . 
  Operation 
 
 , 
  
  error 
 
 ) 
 
 
GetOperation is a utility method from google.longrunning.Operations.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 longrunningpb 
  
 "cloud.google.com/go/longrunning/autogen/longrunningpb" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& longrunningpb 
 . 
  GetOperationRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetOperation 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
 
func (*OrgPolicyViolationsPreviewClient) GetOrgPolicyViolationsPreview
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 GetOrgPolicyViolationsPreview 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  policysimulatorpb 
 
 . 
  GetOrgPolicyViolationsPreviewRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  OrgPolicyViolationsPreview 
 
 , 
  
  error 
 
 ) 
 
 
GetOrgPolicyViolationsPreview getOrgPolicyViolationsPreview gets the specified OrgPolicyViolationsPreview. Each OrgPolicyViolationsPreview is available for at least 7 days.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 GetOrgPolicyViolationsPreviewRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#GetOrgPolicyViolationsPreviewRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetOrgPolicyViolationsPreview 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
 
func (*OrgPolicyViolationsPreviewClient) ListOperations
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 ListOperations 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  longrunningpb 
 
 . 
  ListOperationsRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 * 
  OperationIterator 
 
 
 
ListOperations is a utility method from google.longrunning.Operations.
Examples
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 longrunningpb 
  
 "cloud.google.com/go/longrunning/autogen/longrunningpb" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& longrunningpb 
 . 
  ListOperationsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListOperations 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 longrunningpb 
 . 
  ListOperationsResponse 
 
 ) 
  
 } 
 } 
 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 longrunningpb 
  
 "cloud.google.com/go/longrunning/autogen/longrunningpb" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& longrunningpb 
 . 
  ListOperationsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 ListOperations 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 
 
func (*OrgPolicyViolationsPreviewClient) ListOrgPolicyViolations
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 ListOrgPolicyViolations 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  policysimulatorpb 
 
 . 
  ListOrgPolicyViolationsRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 * 
  OrgPolicyViolationIterator 
 
 
 
ListOrgPolicyViolations listOrgPolicyViolations lists the OrgPolicyViolations that are present in an OrgPolicyViolationsPreview.
Examples
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 ListOrgPolicyViolationsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListOrgPolicyViolationsRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListOrgPolicyViolations 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 policysimulatorpb 
 . 
 ListOrgPolicyViolationsResponse 
 ) 
  
 } 
 } 
 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 ListOrgPolicyViolationsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListOrgPolicyViolationsRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 ListOrgPolicyViolations 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 
 
func (*OrgPolicyViolationsPreviewClient) ListOrgPolicyViolationsPreviews
  func 
  
 ( 
 c 
  
 * 
  OrgPolicyViolationsPreviewClient 
 
 ) 
  
 ListOrgPolicyViolationsPreviews 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  policysimulatorpb 
 
 . 
  ListOrgPolicyViolationsPreviewsRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 * 
  OrgPolicyViolationsPreviewIterator 
 
 
 
ListOrgPolicyViolationsPreviews listOrgPolicyViolationsPreviews lists each OrgPolicyViolationsPreview in an organization. Each OrgPolicyViolationsPreview is available for at least 7 days.
Examples
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 ListOrgPolicyViolationsPreviewsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListOrgPolicyViolationsPreviewsRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListOrgPolicyViolationsPreviews 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 policysimulatorpb 
 . 
 ListOrgPolicyViolationsPreviewsResponse 
 ) 
  
 } 
 } 
 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewOrgPolicyViolationsPreviewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 ListOrgPolicyViolationsPreviewsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListOrgPolicyViolationsPreviewsRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 ListOrgPolicyViolationsPreviews 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 
 
OrgPolicyViolationsPreviewIterator
  type 
  
 OrgPolicyViolationsPreviewIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  policysimulatorpb 
 
 . 
  OrgPolicyViolationsPreview 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 
 
OrgPolicyViolationsPreviewIterator manages a stream of *policysimulatorpb.OrgPolicyViolationsPreview.
func (*OrgPolicyViolationsPreviewIterator) All
  func 
  
 ( 
 it 
  
 * 
  OrgPolicyViolationsPreviewIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 policysimulatorpb 
 . 
 OrgPolicyViolationsPreview 
 , 
  
 error 
 ] 
 
 
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*OrgPolicyViolationsPreviewIterator) Next
  func 
  
 ( 
 it 
  
 * 
  OrgPolicyViolationsPreviewIterator 
 
 ) 
  
 Next 
 () 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  OrgPolicyViolationsPreview 
 
 , 
  
  error 
 
 ) 
 
 
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*OrgPolicyViolationsPreviewIterator) PageInfo
  func 
  
 ( 
 it 
  
 * 
  OrgPolicyViolationsPreviewIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 
 
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ReplayResultIterator
  type 
  
 ReplayResultIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  policysimulatorpb 
 
 . 
  ReplayResult 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 
 
ReplayResultIterator manages a stream of *policysimulatorpb.ReplayResult.
func (*ReplayResultIterator) All
  func 
  
 ( 
 it 
  
 * 
  ReplayResultIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 policysimulatorpb 
 . 
 ReplayResult 
 , 
  
 error 
 ] 
 
 
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ReplayResultIterator) Next
  func 
  
 ( 
 it 
  
 * 
  ReplayResultIterator 
 
 ) 
  
 Next 
 () 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  ReplayResult 
 
 , 
  
  error 
 
 ) 
 
 
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ReplayResultIterator) PageInfo
  func 
  
 ( 
 it 
  
 * 
  ReplayResultIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 
 
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
SimulatorCallOptions
  type 
  
 SimulatorCallOptions 
  
 struct 
  
 { 
  
 GetReplay 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CreateReplay 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListReplayResults 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetOperation 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListOperations 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 
 
SimulatorCallOptions contains the retry settings for each method of SimulatorClient.
SimulatorClient
  type 
  
 SimulatorClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  SimulatorCallOptions 
 
  
 // LROClient is used internally to handle long-running operations. 
  
 // It is exposed so that its CallOptions can be modified if required. 
  
 // Users should not Close this client. 
  
 LROClient 
  
 * 
  lroauto 
 
 . 
  OperationsClient 
 
  
 // contains filtered or unexported fields 
 } 
 
 
SimulatorClient is a client for interacting with Policy Simulator API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Policy Simulator API service.
Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay. A Replay is a type of simulation that lets you see how your principals’ access to resources might change if you changed your IAM policy.
During a Replay, Policy Simulator re-evaluates, or replays, past access attempts under both the current policy and your proposed policy, and compares those results to determine how your principals’ access might change under the proposed policy.
func NewSimulatorClient
  func 
  
 NewSimulatorClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  SimulatorClient 
 
 , 
  
  error 
 
 ) 
 
 
NewSimulatorClient creates a new simulator client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Policy Simulator API service.
Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay. A Replay is a type of simulation that lets you see how your principals’ access to resources might change if you changed your IAM policy.
During a Replay, Policy Simulator re-evaluates, or replays, past access attempts under both the current policy and your proposed policy, and compares those results to determine how your principals’ access might change under the proposed policy.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 
 
func NewSimulatorRESTClient
  func 
  
 NewSimulatorRESTClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  SimulatorClient 
 
 , 
  
  error 
 
 ) 
 
 
NewSimulatorRESTClient creates a new simulator rest client.
Policy Simulator API service.
Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay. A Replay is a type of simulation that lets you see how your principals’ access to resources might change if you changed your IAM policy.
During a Replay, Policy Simulator re-evaluates, or replays, past access attempts under both the current policy and your proposed policy, and compares those results to determine how your principals’ access might change under the proposed policy.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
  NewSimulatorRESTClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 
 
func (*SimulatorClient) Close
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 
 
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*SimulatorClient) Connection (deprecated)
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 Connection 
 () 
  
 * 
 grpc 
 . 
 ClientConn 
 
 
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SimulatorClient) CreateReplay
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 CreateReplay 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  policysimulatorpb 
 
 . 
  CreateReplayRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  CreateReplayOperation 
 
 , 
  
  error 
 
 ) 
 
 
CreateReplay creates and starts a Replay using the given ReplayConfig.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 CreateReplayRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#CreateReplayRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateReplay 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
 
func (*SimulatorClient) CreateReplayOperation
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 CreateReplayOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  CreateReplayOperation 
 
 
 
CreateReplayOperation returns a new CreateReplayOperation from a given name. The name must be that of a previously created CreateReplayOperation, possibly from a different process.
func (*SimulatorClient) GetOperation
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 GetOperation 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  longrunningpb 
 
 . 
  GetOperationRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  longrunningpb 
 
 . 
  Operation 
 
 , 
  
  error 
 
 ) 
 
 
GetOperation is a utility method from google.longrunning.Operations.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 longrunningpb 
  
 "cloud.google.com/go/longrunning/autogen/longrunningpb" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& longrunningpb 
 . 
  GetOperationRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetOperation 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
 
func (*SimulatorClient) GetReplay
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 GetReplay 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  policysimulatorpb 
 
 . 
  GetReplayRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 ( 
 * 
  policysimulatorpb 
 
 . 
  Replay 
 
 , 
  
  error 
 
 ) 
 
 
GetReplay gets the specified Replay. Each Replay is available for at least 7 days.
Example
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 GetReplayRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#GetReplayRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetReplay 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
 
func (*SimulatorClient) ListOperations
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 ListOperations 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  longrunningpb 
 
 . 
  ListOperationsRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 * 
  OperationIterator 
 
 
 
ListOperations is a utility method from google.longrunning.Operations.
Examples
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 longrunningpb 
  
 "cloud.google.com/go/longrunning/autogen/longrunningpb" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& longrunningpb 
 . 
  ListOperationsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListOperations 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 longrunningpb 
 . 
  ListOperationsResponse 
 
 ) 
  
 } 
 } 
 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 longrunningpb 
  
 "cloud.google.com/go/longrunning/autogen/longrunningpb" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& longrunningpb 
 . 
  ListOperationsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 ListOperations 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 
 
func (*SimulatorClient) ListReplayResults
  func 
  
 ( 
 c 
  
 * 
  SimulatorClient 
 
 ) 
  
 ListReplayResults 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  policysimulatorpb 
 
 . 
  ListReplayResultsRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
 * 
  ReplayResultIterator 
 
 
 
ListReplayResults lists the results of running a Replay.
Examples
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 ListReplayResultsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListReplayResultsRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListReplayResults 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 policysimulatorpb 
 . 
 ListReplayResultsResponse 
 ) 
  
 } 
 } 
 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 policysimulator 
  
 "cloud.google.com/go/policysimulator/apiv1" 
  
 policysimulatorpb 
  
 "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 policysimulator 
 . 
 NewSimulatorClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& policysimulatorpb 
 . 
 ListReplayResultsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListReplayResultsRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 ListReplayResults 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 
 

