Access Approval API v1 - Package cloud.google.com/go/accessapproval/apiv1 (v1.8.8) Stay organized with collections Save and categorize content based on your preferences.
Package accessapproval is an auto-generated package for theAccess Approval API.
An API for controlling access to data by Google personnel.
General documentation
For information that is relevant for all client libraries please referencehttps://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on thispage 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/accessapproval/apiv1@latestctx:=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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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:=&accessapprovalpb.ApproveApprovalRequestMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#ApproveApprovalRequestMessage.}resp,err:=c.ApproveApprovalRequest(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp
Use of Context
The ctx passed to NewClient is used for authentication requests andfor 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
funcDefaultAuthScopes()[]stringDefaultAuthScopes reports the default set of authentication scopes to use with this package.
ApprovalRequestIterator
typeApprovalRequestIteratorstruct{// 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.Responseinterface{}// 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.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*accessapprovalpb.ApprovalRequest,nextPageTokenstring,errerror)// contains filtered or unexported fields}ApprovalRequestIterator manages a stream of *accessapprovalpb.ApprovalRequest.
func (*ApprovalRequestIterator) All
func(it*ApprovalRequestIterator)All()iter.Seq2[*accessapprovalpb.ApprovalRequest,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*ApprovalRequestIterator) Next
func(it*ApprovalRequestIterator)Next()(*accessapprovalpb.ApprovalRequest,error)Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.
func (*ApprovalRequestIterator) PageInfo
func(it*ApprovalRequestIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
CallOptions
typeCallOptionsstruct{ListApprovalRequests[]gax.CallOptionGetApprovalRequest[]gax.CallOptionApproveApprovalRequest[]gax.CallOptionDismissApprovalRequest[]gax.CallOptionInvalidateApprovalRequest[]gax.CallOptionGetAccessApprovalSettings[]gax.CallOptionUpdateAccessApprovalSettings[]gax.CallOptionDeleteAccessApprovalSettings[]gax.CallOptionGetAccessApprovalServiceAccount[]gax.CallOption}CallOptions contains the retry settings for each method of Client.
Client
typeClientstruct{// The call options for this service.CallOptions*CallOptions// contains filtered or unexported fields}Client is a client for interacting with Access Approval API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
This API allows a customer to manage accesses to cloud resources byGoogle personnel. It defines the following resource model:
The API has a collection ofApprovalRequestresources, named approvalRequests/{approval_request}The API has top-level settings per Project/Folder/Organization, namedaccessApprovalSettingsThe service also periodically emails a list of recipients, defined at theProject/Folder/Organization level in the accessApprovalSettings, when thereis a pending ApprovalRequest for them to act on. The ApprovalRequests canalso optionally be published to a Pub/Sub topic owned by the customer(contact support if you would like to enable Pub/Sub notifications).
ApprovalRequests can be approved or dismissed. Google personnel can onlyaccess the indicated resource or resources if the request is approved(subject to some exclusions:https://cloud.google.com/access-approval/docs/overview#exclusions (athttps://cloud.google.com/access-approval/docs/overview#exclusions)).
Note: Using Access Approval functionality will mean that Google may not beable to meet the SLAs for your chosen products, as any support response timesmay be dramatically increased. As such the SLAs do not apply to any servicedisruption to the extent impacted by Customer’s use of Access Approval. Donot enable Access Approval for projects where you may require high serviceavailability and rapid response by Google Cloud Support.
After a request is approved or dismissed, no further action may be taken onit. Requests with the requested_expiration in the past or with no activityfor 14 days are considered dismissed. When an approval expires, the requestis considered dismissed.
If a request is not approved or dismissed, we call it pending.
func NewClient
NewClient creates a new access approval client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
This API allows a customer to manage accesses to cloud resources byGoogle personnel. It defines the following resource model:
The API has a collection ofApprovalRequestresources, named approvalRequests/{approval_request}The API has top-level settings per Project/Folder/Organization, namedaccessApprovalSettingsThe service also periodically emails a list of recipients, defined at theProject/Folder/Organization level in the accessApprovalSettings, when thereis a pending ApprovalRequest for them to act on. The ApprovalRequests canalso optionally be published to a Pub/Sub topic owned by the customer(contact support if you would like to enable Pub/Sub notifications).
ApprovalRequests can be approved or dismissed. Google personnel can onlyaccess the indicated resource or resources if the request is approved(subject to some exclusions:https://cloud.google.com/access-approval/docs/overview#exclusions (athttps://cloud.google.com/access-approval/docs/overview#exclusions)).
Note: Using Access Approval functionality will mean that Google may not beable to meet the SLAs for your chosen products, as any support response timesmay be dramatically increased. As such the SLAs do not apply to any servicedisruption to the extent impacted by Customer’s use of Access Approval. Donot enable Access Approval for projects where you may require high serviceavailability and rapid response by Google Cloud Support.
After a request is approved or dismissed, no further action may be taken onit. Requests with the requested_expiration in the past or with no activityfor 14 days are considered dismissed. When an approval expires, the requestis considered dismissed.
If a request is not approved or dismissed, we call it pending.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewRESTClient
NewRESTClient creates a new access approval rest client.
This API allows a customer to manage accesses to cloud resources byGoogle personnel. It defines the following resource model:
The API has a collection ofApprovalRequestresources, named approvalRequests/{approval_request}The API has top-level settings per Project/Folder/Organization, namedaccessApprovalSettingsThe service also periodically emails a list of recipients, defined at theProject/Folder/Organization level in the accessApprovalSettings, when thereis a pending ApprovalRequest for them to act on. The ApprovalRequests canalso optionally be published to a Pub/Sub topic owned by the customer(contact support if you would like to enable Pub/Sub notifications).
ApprovalRequests can be approved or dismissed. Google personnel can onlyaccess the indicated resource or resources if the request is approved(subject to some exclusions:https://cloud.google.com/access-approval/docs/overview#exclusions (athttps://cloud.google.com/access-approval/docs/overview#exclusions)).
Note: Using Access Approval functionality will mean that Google may not beable to meet the SLAs for your chosen products, as any support response timesmay be dramatically increased. As such the SLAs do not apply to any servicedisruption to the extent impacted by Customer’s use of Access Approval. Donot enable Access Approval for projects where you may require high serviceavailability and rapid response by Google Cloud Support.
After a request is approved or dismissed, no further action may be taken onit. Requests with the requested_expiration in the past or with no activityfor 14 days are considered dismissed. When an approval expires, the requestis considered dismissed.
If a request is not approved or dismissed, we call it pending.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1")funcmain(){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_Optionsc,err:=accessapproval.NewRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*Client) ApproveApprovalRequest
func(c*Client)ApproveApprovalRequest(ctxcontext.Context,req*accessapprovalpb.ApproveApprovalRequestMessage,opts...gax.CallOption)(*accessapprovalpb.ApprovalRequest,error)ApproveApprovalRequest approves a request and returns the updated ApprovalRequest.
Returns NOT_FOUND if the request does not exist. ReturnsFAILED_PRECONDITION if the request exists but is not in a pending state.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.ApproveApprovalRequestMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#ApproveApprovalRequestMessage.}resp,err:=c.ApproveApprovalRequest(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*Client) Close
Close closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*Client) Connection (deprecated)
func(c*Client)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*Client) DeleteAccessApprovalSettings
func(c*Client)DeleteAccessApprovalSettings(ctxcontext.Context,req*accessapprovalpb.DeleteAccessApprovalSettingsMessage,opts...gax.CallOption)errorDeleteAccessApprovalSettings 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 AccessApproval disabled. If Access Approval is enabled at a higher level of thehierarchy, then Access Approval will still be enabled at this level asthe settings are inherited.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.DeleteAccessApprovalSettingsMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#DeleteAccessApprovalSettingsMessage.}err=c.DeleteAccessApprovalSettings(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*Client) DismissApprovalRequest
func(c*Client)DismissApprovalRequest(ctxcontext.Context,req*accessapprovalpb.DismissApprovalRequestMessage,opts...gax.CallOption)(*accessapprovalpb.ApprovalRequest,error)DismissApprovalRequest dismisses a request. Returns the updated ApprovalRequest.
NOTE: This does not deny access to the resource if another request has beenmade and approved. It is equivalent in effect to ignoring the requestaltogether.
Returns NOT_FOUND if the request does not exist.
Returns FAILED_PRECONDITION if the request exists but is not in a pendingstate.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.DismissApprovalRequestMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#DismissApprovalRequestMessage.}resp,err:=c.DismissApprovalRequest(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*Client) GetAccessApprovalServiceAccount
func(c*Client)GetAccessApprovalServiceAccount(ctxcontext.Context,req*accessapprovalpb.GetAccessApprovalServiceAccountMessage,opts...gax.CallOption)(*accessapprovalpb.AccessApprovalServiceAccount,error)GetAccessApprovalServiceAccount retrieves the service account that is used by Access Approval to access KMSkeys for signing approved approval requests.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.GetAccessApprovalServiceAccountMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#GetAccessApprovalServiceAccountMessage.}resp,err:=c.GetAccessApprovalServiceAccount(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*Client) GetAccessApprovalSettings
func(c*Client)GetAccessApprovalSettings(ctxcontext.Context,req*accessapprovalpb.GetAccessApprovalSettingsMessage,opts...gax.CallOption)(*accessapprovalpb.AccessApprovalSettings,error)GetAccessApprovalSettings gets the settings associated with a project, folder, or organization.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.GetAccessApprovalSettingsMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#GetAccessApprovalSettingsMessage.}resp,err:=c.GetAccessApprovalSettings(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*Client) GetApprovalRequest
func(c*Client)GetApprovalRequest(ctxcontext.Context,req*accessapprovalpb.GetApprovalRequestMessage,opts...gax.CallOption)(*accessapprovalpb.ApprovalRequest,error)GetApprovalRequest gets an approval request. Returns NOT_FOUND if the request does not exist.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.GetApprovalRequestMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#GetApprovalRequestMessage.}resp,err:=c.GetApprovalRequest(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*Client) InvalidateApprovalRequest
func(c*Client)InvalidateApprovalRequest(ctxcontext.Context,req*accessapprovalpb.InvalidateApprovalRequestMessage,opts...gax.CallOption)(*accessapprovalpb.ApprovalRequest,error)InvalidateApprovalRequest invalidates an existing ApprovalRequest. Returns the updatedApprovalRequest.
NOTE: This does not deny access to the resource if another request has beenmade and approved. It only invalidates a single approval.
Returns FAILED_PRECONDITION if the request exists but is not in an approvedstate.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.InvalidateApprovalRequestMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#InvalidateApprovalRequestMessage.}resp,err:=c.InvalidateApprovalRequest(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*Client) ListApprovalRequests
func(c*Client)ListApprovalRequests(ctxcontext.Context,req*accessapprovalpb.ListApprovalRequestsMessage,opts...gax.CallOption)*ApprovalRequestIteratorListApprovalRequests 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.
Examples
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.ListApprovalRequestsMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#ListApprovalRequestsMessage.}it:=c.ListApprovalRequests(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=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.(*accessapprovalpb.ListApprovalRequestsResponse)}}all
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.ListApprovalRequestsMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#ListApprovalRequestsMessage.}forresp,err:=rangec.ListApprovalRequests(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*Client) UpdateAccessApprovalSettings
func(c*Client)UpdateAccessApprovalSettings(ctxcontext.Context,req*accessapprovalpb.UpdateAccessApprovalSettingsMessage,opts...gax.CallOption)(*accessapprovalpb.AccessApprovalSettings,error)UpdateAccessApprovalSettings updates the settings associated with a project, folder, or organization.Settings to update are determined by the value of field_mask.
Example
packagemainimport("context"accessapproval"cloud.google.com/go/accessapproval/apiv1"accessapprovalpb"cloud.google.com/go/accessapproval/apiv1/accessapprovalpb")funcmain(){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_Optionsc,err:=accessapproval.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&accessapprovalpb.UpdateAccessApprovalSettingsMessage{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/accessapproval/apiv1/accessapprovalpb#UpdateAccessApprovalSettingsMessage.}resp,err:=c.UpdateAccessApprovalSettings(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-30 UTC.