package iam

import "cloud.google.com/go/iam/apiv3"

Package iam is an auto-generated package for the Identity and Access Management (IAM) API.

Manages identity and access control for Google Cloud resources, including the creation of service accounts, which you can use to authenticate to Google and make API calls. Enabling this API also enables the IAM Service Account Credentials API (iamcredentials.googleapis.com (at http://iamcredentials.googleapis.com)). However, disabling this API doesn’t disable the IAM Service Account Credentials API.

NOTE: This package is in beta. It is not stable, and may be subject to changes.

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:

Example usage

To get started with this package, create a client.

// go get cloud.google.com/go/iam/apiv3@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 := iam.NewPolicyBindingsClient(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 := &iampb.CreatePolicyBindingRequest{
	// TODO: Fill request struct fields.
	// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#CreatePolicyBindingRequest.
}
op, err := c.CreatePolicyBinding(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 NewPolicyBindingsClient 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.

Index

Examples

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

Types

type CreatePolicyBindingOperation

type CreatePolicyBindingOperation struct {
	// contains filtered or unexported fields
}

CreatePolicyBindingOperation manages a long-running operation from CreatePolicyBinding.

func (*CreatePolicyBindingOperation) Done

Done reports whether the long-running operation has completed.

func (*CreatePolicyBindingOperation) Metadata

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 (*CreatePolicyBindingOperation) Name

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 (*CreatePolicyBindingOperation) Poll

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 (*CreatePolicyBindingOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type CreatePrincipalAccessBoundaryPolicyOperation

type CreatePrincipalAccessBoundaryPolicyOperation struct {
	// contains filtered or unexported fields
}

CreatePrincipalAccessBoundaryPolicyOperation manages a long-running operation from CreatePrincipalAccessBoundaryPolicy.

func (*CreatePrincipalAccessBoundaryPolicyOperation) Done

Done reports whether the long-running operation has completed.

func (*CreatePrincipalAccessBoundaryPolicyOperation) Metadata

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 (*CreatePrincipalAccessBoundaryPolicyOperation) Name

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 (*CreatePrincipalAccessBoundaryPolicyOperation) Poll

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 (*CreatePrincipalAccessBoundaryPolicyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type DeletePolicyBindingOperation

type DeletePolicyBindingOperation struct {
	// contains filtered or unexported fields
}

DeletePolicyBindingOperation manages a long-running operation from DeletePolicyBinding.

func (*DeletePolicyBindingOperation) Done

Done reports whether the long-running operation has completed.

func (*DeletePolicyBindingOperation) Metadata

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 (*DeletePolicyBindingOperation) Name

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 (*DeletePolicyBindingOperation) Poll

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 (*DeletePolicyBindingOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type DeletePrincipalAccessBoundaryPolicyOperation

type DeletePrincipalAccessBoundaryPolicyOperation struct {
	// contains filtered or unexported fields
}

DeletePrincipalAccessBoundaryPolicyOperation manages a long-running operation from DeletePrincipalAccessBoundaryPolicy.

func (*DeletePrincipalAccessBoundaryPolicyOperation) Done

Done reports whether the long-running operation has completed.

func (*DeletePrincipalAccessBoundaryPolicyOperation) Metadata

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 (*DeletePrincipalAccessBoundaryPolicyOperation) Name

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 (*DeletePrincipalAccessBoundaryPolicyOperation) Poll

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 (*DeletePrincipalAccessBoundaryPolicyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type PolicyBindingIterator

type PolicyBindingIterator 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 []*iampb.PolicyBinding, nextPageToken string, err error)
	// contains filtered or unexported fields
}

PolicyBindingIterator manages a stream of *iampb.PolicyBinding.

func (*PolicyBindingIterator) All

All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.

func (*PolicyBindingIterator) Next

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 (*PolicyBindingIterator) PageInfo

func (it *PolicyBindingIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type PolicyBindingsCallOptions

type PolicyBindingsCallOptions struct {
	CreatePolicyBinding        []gax.CallOption
	GetPolicyBinding           []gax.CallOption
	UpdatePolicyBinding        []gax.CallOption
	DeletePolicyBinding        []gax.CallOption
	ListPolicyBindings         []gax.CallOption
	SearchTargetPolicyBindings []gax.CallOption
	GetOperation               []gax.CallOption
}

PolicyBindingsCallOptions contains the retry settings for each method of PolicyBindingsClient.

type PolicyBindingsClient

type PolicyBindingsClient struct {

	// The call options for this service.
	CallOptions *PolicyBindingsCallOptions

	// 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
}

PolicyBindingsClient is a client for interacting with Identity and Access Management (IAM) API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

An interface for managing Identity and Access Management (IAM) policy bindings.

func NewPolicyBindingsClient

func NewPolicyBindingsClient(ctx context.Context, opts ...option.ClientOption) (*PolicyBindingsClient, error)

NewPolicyBindingsClient creates a new policy bindings client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

An interface for managing Identity and Access Management (IAM) policy bindings.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
)

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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func NewPolicyBindingsRESTClient

func NewPolicyBindingsRESTClient(ctx context.Context, opts ...option.ClientOption) (*PolicyBindingsClient, error)

NewPolicyBindingsRESTClient creates a new policy bindings rest client.

An interface for managing Identity and Access Management (IAM) policy bindings.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
)

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 := iam.NewPolicyBindingsRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*PolicyBindingsClient) Close

func (c *PolicyBindingsClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*PolicyBindingsClient) Connection

func (c *PolicyBindingsClient) 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 (*PolicyBindingsClient) CreatePolicyBinding

CreatePolicyBinding creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.CreatePolicyBindingRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#CreatePolicyBindingRequest.
	}
	op, err := c.CreatePolicyBinding(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*PolicyBindingsClient) CreatePolicyBindingOperation

func (c *PolicyBindingsClient) CreatePolicyBindingOperation(name string) *CreatePolicyBindingOperation

CreatePolicyBindingOperation returns a new CreatePolicyBindingOperation from a given name. The name must be that of a previously created CreatePolicyBindingOperation, possibly from a different process.

func (*PolicyBindingsClient) DeletePolicyBinding

DeletePolicyBinding deletes a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.DeletePolicyBindingRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#DeletePolicyBindingRequest.
	}
	op, err := c.DeletePolicyBinding(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*PolicyBindingsClient) DeletePolicyBindingOperation

func (c *PolicyBindingsClient) DeletePolicyBindingOperation(name string) *DeletePolicyBindingOperation

DeletePolicyBindingOperation returns a new DeletePolicyBindingOperation from a given name. The name must be that of a previously created DeletePolicyBindingOperation, possibly from a different process.

func (*PolicyBindingsClient) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"

	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
)

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 := iam.NewPolicyBindingsClient(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 (*PolicyBindingsClient) GetPolicyBinding

GetPolicyBinding gets a policy binding.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.GetPolicyBindingRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#GetPolicyBindingRequest.
	}
	resp, err := c.GetPolicyBinding(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*PolicyBindingsClient) ListPolicyBindings

ListPolicyBindings lists policy bindings.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
	"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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.ListPolicyBindingsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#ListPolicyBindingsRequest.
	}
	it := c.ListPolicyBindings(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.(*iampb.ListPolicyBindingsResponse)
	}
}
Example (All)

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.ListPolicyBindingsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#ListPolicyBindingsRequest.
	}
	for resp, err := range c.ListPolicyBindings(ctx, req).All() {
		if err != nil {
			// TODO: Handle error and break/return/continue. Iteration will stop after any error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*PolicyBindingsClient) SearchTargetPolicyBindings

SearchTargetPolicyBindings search policy bindings by target. Returns all policy binding objects bound directly to target.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
	"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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.SearchTargetPolicyBindingsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#SearchTargetPolicyBindingsRequest.
	}
	it := c.SearchTargetPolicyBindings(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.(*iampb.SearchTargetPolicyBindingsResponse)
	}
}
Example (All)

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.SearchTargetPolicyBindingsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#SearchTargetPolicyBindingsRequest.
	}
	for resp, err := range c.SearchTargetPolicyBindings(ctx, req).All() {
		if err != nil {
			// TODO: Handle error and break/return/continue. Iteration will stop after any error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*PolicyBindingsClient) UpdatePolicyBinding

UpdatePolicyBinding updates a policy binding and returns a long-running operation. Callers will need the IAM permissions on the policy and target in the binding to update, and the IAM permission to remove the existing policy from the binding. Target is immutable and cannot be updated. Once the binding is updated, the new policy is applied to the target.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPolicyBindingsClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.UpdatePolicyBindingRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#UpdatePolicyBindingRequest.
	}
	op, err := c.UpdatePolicyBinding(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*PolicyBindingsClient) UpdatePolicyBindingOperation

func (c *PolicyBindingsClient) UpdatePolicyBindingOperation(name string) *UpdatePolicyBindingOperation

UpdatePolicyBindingOperation returns a new UpdatePolicyBindingOperation from a given name. The name must be that of a previously created UpdatePolicyBindingOperation, possibly from a different process.

type PrincipalAccessBoundaryPoliciesCallOptions

type PrincipalAccessBoundaryPoliciesCallOptions struct {
	CreatePrincipalAccessBoundaryPolicy         []gax.CallOption
	GetPrincipalAccessBoundaryPolicy            []gax.CallOption
	UpdatePrincipalAccessBoundaryPolicy         []gax.CallOption
	DeletePrincipalAccessBoundaryPolicy         []gax.CallOption
	ListPrincipalAccessBoundaryPolicies         []gax.CallOption
	SearchPrincipalAccessBoundaryPolicyBindings []gax.CallOption
	GetOperation                                []gax.CallOption
}

PrincipalAccessBoundaryPoliciesCallOptions contains the retry settings for each method of PrincipalAccessBoundaryPoliciesClient.

type PrincipalAccessBoundaryPoliciesClient

type PrincipalAccessBoundaryPoliciesClient struct {

	// The call options for this service.
	CallOptions *PrincipalAccessBoundaryPoliciesCallOptions

	// 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
}

PrincipalAccessBoundaryPoliciesClient is a client for interacting with Identity and Access Management (IAM) API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Manages Identity and Access Management (IAM) principal access boundary policies.

func NewPrincipalAccessBoundaryPoliciesClient

func NewPrincipalAccessBoundaryPoliciesClient(ctx context.Context, opts ...option.ClientOption) (*PrincipalAccessBoundaryPoliciesClient, error)

NewPrincipalAccessBoundaryPoliciesClient creates a new principal access boundary policies client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Manages Identity and Access Management (IAM) principal access boundary policies.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func NewPrincipalAccessBoundaryPoliciesRESTClient

func NewPrincipalAccessBoundaryPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*PrincipalAccessBoundaryPoliciesClient, error)

NewPrincipalAccessBoundaryPoliciesRESTClient creates a new principal access boundary policies rest client.

Manages Identity and Access Management (IAM) principal access boundary policies.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*PrincipalAccessBoundaryPoliciesClient) Close

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*PrincipalAccessBoundaryPoliciesClient) Connection

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*PrincipalAccessBoundaryPoliciesClient) CreatePrincipalAccessBoundaryPolicy

CreatePrincipalAccessBoundaryPolicy creates a principal access boundary policy, and returns a long running operation.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.CreatePrincipalAccessBoundaryPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#CreatePrincipalAccessBoundaryPolicyRequest.
	}
	op, err := c.CreatePrincipalAccessBoundaryPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*PrincipalAccessBoundaryPoliciesClient) CreatePrincipalAccessBoundaryPolicyOperation

func (c *PrincipalAccessBoundaryPoliciesClient) CreatePrincipalAccessBoundaryPolicyOperation(name string) *CreatePrincipalAccessBoundaryPolicyOperation

CreatePrincipalAccessBoundaryPolicyOperation returns a new CreatePrincipalAccessBoundaryPolicyOperation from a given name. The name must be that of a previously created CreatePrincipalAccessBoundaryPolicyOperation, possibly from a different process.

func (*PrincipalAccessBoundaryPoliciesClient) DeletePrincipalAccessBoundaryPolicy

DeletePrincipalAccessBoundaryPolicy deletes a principal access boundary policy.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.DeletePrincipalAccessBoundaryPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#DeletePrincipalAccessBoundaryPolicyRequest.
	}
	op, err := c.DeletePrincipalAccessBoundaryPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*PrincipalAccessBoundaryPoliciesClient) DeletePrincipalAccessBoundaryPolicyOperation

func (c *PrincipalAccessBoundaryPoliciesClient) DeletePrincipalAccessBoundaryPolicyOperation(name string) *DeletePrincipalAccessBoundaryPolicyOperation

DeletePrincipalAccessBoundaryPolicyOperation returns a new DeletePrincipalAccessBoundaryPolicyOperation from a given name. The name must be that of a previously created DeletePrincipalAccessBoundaryPolicyOperation, possibly from a different process.

func (*PrincipalAccessBoundaryPoliciesClient) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"

	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(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 (*PrincipalAccessBoundaryPoliciesClient) GetPrincipalAccessBoundaryPolicy

GetPrincipalAccessBoundaryPolicy gets a principal access boundary policy.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.GetPrincipalAccessBoundaryPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#GetPrincipalAccessBoundaryPolicyRequest.
	}
	resp, err := c.GetPrincipalAccessBoundaryPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*PrincipalAccessBoundaryPoliciesClient) ListPrincipalAccessBoundaryPolicies

ListPrincipalAccessBoundaryPolicies lists principal access boundary policies.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
	"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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.ListPrincipalAccessBoundaryPoliciesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#ListPrincipalAccessBoundaryPoliciesRequest.
	}
	it := c.ListPrincipalAccessBoundaryPolicies(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.(*iampb.ListPrincipalAccessBoundaryPoliciesResponse)
	}
}
Example (All)

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.ListPrincipalAccessBoundaryPoliciesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#ListPrincipalAccessBoundaryPoliciesRequest.
	}
	for resp, err := range c.ListPrincipalAccessBoundaryPolicies(ctx, req).All() {
		if err != nil {
			// TODO: Handle error and break/return/continue. Iteration will stop after any error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*PrincipalAccessBoundaryPoliciesClient) SearchPrincipalAccessBoundaryPolicyBindings

SearchPrincipalAccessBoundaryPolicyBindings returns all policy bindings that bind a specific policy if a user has searchPolicyBindings permission on that policy.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
	"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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.SearchPrincipalAccessBoundaryPolicyBindingsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#SearchPrincipalAccessBoundaryPolicyBindingsRequest.
	}
	it := c.SearchPrincipalAccessBoundaryPolicyBindings(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.(*iampb.SearchPrincipalAccessBoundaryPolicyBindingsResponse)
	}
}
Example (All)

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.SearchPrincipalAccessBoundaryPolicyBindingsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#SearchPrincipalAccessBoundaryPolicyBindingsRequest.
	}
	for resp, err := range c.SearchPrincipalAccessBoundaryPolicyBindings(ctx, req).All() {
		if err != nil {
			// TODO: Handle error and break/return/continue. Iteration will stop after any error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*PrincipalAccessBoundaryPoliciesClient) UpdatePrincipalAccessBoundaryPolicy

UpdatePrincipalAccessBoundaryPolicy updates a principal access boundary policy.

Example

Code:play 

package main

import (
	"context"

	iam "cloud.google.com/go/iam/apiv3"
	iampb "cloud.google.com/go/iam/apiv3/iampb"
)

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 := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.UpdatePrincipalAccessBoundaryPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#UpdatePrincipalAccessBoundaryPolicyRequest.
	}
	op, err := c.UpdatePrincipalAccessBoundaryPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*PrincipalAccessBoundaryPoliciesClient) UpdatePrincipalAccessBoundaryPolicyOperation

func (c *PrincipalAccessBoundaryPoliciesClient) UpdatePrincipalAccessBoundaryPolicyOperation(name string) *UpdatePrincipalAccessBoundaryPolicyOperation

UpdatePrincipalAccessBoundaryPolicyOperation returns a new UpdatePrincipalAccessBoundaryPolicyOperation from a given name. The name must be that of a previously created UpdatePrincipalAccessBoundaryPolicyOperation, possibly from a different process.

type PrincipalAccessBoundaryPolicyIterator

type PrincipalAccessBoundaryPolicyIterator 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 []*iampb.PrincipalAccessBoundaryPolicy, nextPageToken string, err error)
	// contains filtered or unexported fields
}

PrincipalAccessBoundaryPolicyIterator manages a stream of *iampb.PrincipalAccessBoundaryPolicy.

func (*PrincipalAccessBoundaryPolicyIterator) All

All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.

func (*PrincipalAccessBoundaryPolicyIterator) Next

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 (*PrincipalAccessBoundaryPolicyIterator) PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type UpdatePolicyBindingOperation

type UpdatePolicyBindingOperation struct {
	// contains filtered or unexported fields
}

UpdatePolicyBindingOperation manages a long-running operation from UpdatePolicyBinding.

func (*UpdatePolicyBindingOperation) Done

Done reports whether the long-running operation has completed.

func (*UpdatePolicyBindingOperation) Metadata

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 (*UpdatePolicyBindingOperation) Name

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 (*UpdatePolicyBindingOperation) Poll

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 (*UpdatePolicyBindingOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

type UpdatePrincipalAccessBoundaryPolicyOperation

type UpdatePrincipalAccessBoundaryPolicyOperation struct {
	// contains filtered or unexported fields
}

UpdatePrincipalAccessBoundaryPolicyOperation manages a long-running operation from UpdatePrincipalAccessBoundaryPolicy.

func (*UpdatePrincipalAccessBoundaryPolicyOperation) Done

Done reports whether the long-running operation has completed.

func (*UpdatePrincipalAccessBoundaryPolicyOperation) Metadata

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 (*UpdatePrincipalAccessBoundaryPolicyOperation) Name

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 (*UpdatePrincipalAccessBoundaryPolicyOperation) Poll

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 (*UpdatePrincipalAccessBoundaryPolicyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

Source Files

auxiliary.go auxiliary_go123.go doc.go helpers.go policy_bindings_client.go principal_access_boundary_policies_client.go version.go

Directories

PathSynopsis
apiv3/iampb
Version
v1.5.2 (latest)
Published
Apr 15, 2025
Platform
js/wasm
Imports
29 packages
Last checked
3 hours ago

Tools for package owners.