Access Approval API v1 - Package cloud.google.com/go/accessapproval/apiv1 (v0.75.0)

Use of Context

The ctx passed to NewClient 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.

For information about setting deadlines, reusing contexts, and more please visit pkg.go.dev/cloud.google.com/go.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

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

ApprovalRequestIterator

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

ApprovalRequestIterator manages a stream of *accessapprovalpb.ApprovalRequest.

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

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

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

CallOptions

type CallOptions struct {
	ListApprovalRequests         []gax.CallOption
	GetApprovalRequest           []gax.CallOption
	ApproveApprovalRequest       []gax.CallOption
	DismissApprovalRequest       []gax.CallOption
	GetAccessApprovalSettings    []gax.CallOption
	UpdateAccessApprovalSettings []gax.CallOption
	DeleteAccessApprovalSettings []gax.CallOption
}

CallOptions contains the retry settings for each method of Client.

Client

type Client struct {

	// The call options for this service.
	CallOptions *CallOptions
	// contains filtered or unexported fields
}

Client is a client for interacting with .

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewClient

func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)

NewClient creates a new access approval client.

This API allows a customer to manage accesses to cloud resources by Google personnel. It defines the following resource model:

The API has a collection of ApprovalRequest resources, named approvalRequests/{approval_request_id}

The API has top-level settings per Project/Folder/Organization, named accessApprovalSettings

The service also periodically emails a list of recipients, defined at the Project/Folder/Organization level in the accessApprovalSettings, when there is a pending ApprovalRequest for them to act on. The ApprovalRequests can also optionally be published to a Cloud Pub/Sub topic owned by the customer (for Beta, the Pub/Sub setup is managed manually).

ApprovalRequests can be approved or dismissed. Google personel can only access the indicated resource or resources if the request is approved (subject to some exclusions: https://cloud.google.com/access-approval/docs/overview#exclusions (at https://cloud.google.com/access-approval/docs/overview#exclusions)).

Note: Using Access Approval functionality will mean that Google may not be able to meet the SLAs for your chosen products, as any support response times may be dramatically increased. As such the SLAs do not apply to any service disruption to the extent impacted by Customer’s use of Access Approval. Do not enable Access Approval for projects where you may require high service availability and rapid response by Google Cloud Support.

After a request is approved or dismissed, no further action may be taken on it. Requests with the requested_expiration in the past or with no activity for 14 days are considered dismissed. When an approval expires, the request is considered dismissed.

If a request is not approved or dismissed, we call it pending.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}

func (*Client) ApproveApprovalRequest

ApproveApprovalRequest approves a request and returns the updated ApprovalRequest.

Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"

	accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
)

func main() {
	// import accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"

	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &accessapprovalpb.ApproveApprovalRequestMessage{
		// TODO: Fill request struct fields.
	}
	resp, err := c.ApproveApprovalRequest(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) Close

func (c *Client) Close() error

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

func (*Client) Connection

func (c *Client) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

func (*Client) DeleteAccessApprovalSettings

func (c *Client) DeleteAccessApprovalSettings(ctx context.Context, req *accessapprovalpb.DeleteAccessApprovalSettingsMessage, opts ...gax.CallOption) error

DeleteAccessApprovalSettings deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the project, folder, or organization, but only if all ancestors also have Access Approval disabled. If Access Approval is enabled at a higher level of the hierarchy, then Access Approval will still be enabled at this level as the settings are inherited.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"

	accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
)

func main() {
	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &accessapprovalpb.DeleteAccessApprovalSettingsMessage{
		// TODO: Fill request struct fields.
	}
	err = c.DeleteAccessApprovalSettings(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DismissApprovalRequest

DismissApprovalRequest dismisses a request. Returns the updated ApprovalRequest.

NOTE: This does not deny access to the resource if another request has been made and approved. It is equivalent in effect to ignoring the request altogether.

Returns NOT_FOUND if the request does not exist.

Returns FAILED_PRECONDITION if the request exists but is not in a pending state.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"

	accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
)

func main() {
	// import accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"

	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &accessapprovalpb.DismissApprovalRequestMessage{
		// TODO: Fill request struct fields.
	}
	resp, err := c.DismissApprovalRequest(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetAccessApprovalSettings

GetAccessApprovalSettings gets the settings associated with a project, folder, or organization.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"

	accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
)

func main() {
	// import accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"

	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &accessapprovalpb.GetAccessApprovalSettingsMessage{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetAccessApprovalSettings(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetApprovalRequest

GetApprovalRequest gets an approval request. Returns NOT_FOUND if the request does not exist.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"

	accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
)

func main() {
	// import accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"

	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &accessapprovalpb.GetApprovalRequestMessage{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetApprovalRequest(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) ListApprovalRequests

ListApprovalRequests lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"
	"google.golang.org/api/iterator"

	accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
)

func main() {
	// import accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &accessapprovalpb.ListApprovalRequestsMessage{
		// TODO: Fill request struct fields.
	}
	it := c.ListApprovalRequests(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*Client) UpdateAccessApprovalSettings

UpdateAccessApprovalSettings updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.

Example

package main

import (
	"context"

	accessapproval "cloud.google.com/go/accessapproval/apiv1"

	accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"
)

func main() {
	// import accessapprovalpb "google.golang.org/genproto/googleapis/cloud/accessapproval/v1"

	ctx := context.Background()
	c, err := accessapproval.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &accessapprovalpb.UpdateAccessApprovalSettingsMessage{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateAccessApprovalSettings(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}