Cloud Resource Manager API v2 - Package cloud.google.com/go/resourcemanager/apiv2 (v1.10.7) Stay organized with collections Save and categorize content based on your preferences.
Package resourcemanager is an auto-generated package for theCloud Resource Manager API.
Creates, reads, and updates metadata for Google Cloud Platform resourcecontainers.
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/resourcemanager/apiv2@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:=resourcemanager.NewFoldersClient(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:=&resourcemanagerpb.CreateFolderRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#CreateFolderRequest.}op,err:=c.CreateFolder(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp
Use of Context
The ctx passed to NewFoldersClient 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.
CreateFolderOperation
typeCreateFolderOperationstruct{// contains filtered or unexported fields}CreateFolderOperation manages a long-running operation from CreateFolder.
func (*CreateFolderOperation) Done
func(op*CreateFolderOperation)Done()boolDone reports whether the long-running operation has completed.
func (*CreateFolderOperation) Metadata
func(op*CreateFolderOperation)Metadata()(*resourcemanagerpb.FolderOperation,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 (*CreateFolderOperation) Name
func(op*CreateFolderOperation)Name()stringName 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 (*CreateFolderOperation) Poll
func(op*CreateFolderOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*resourcemanagerpb.Folder,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 andthe 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 (*CreateFolderOperation) Wait
func(op*CreateFolderOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*resourcemanagerpb.Folder,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.
FolderIterator
typeFolderIteratorstruct{// 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[]*resourcemanagerpb.Folder,nextPageTokenstring,errerror)// contains filtered or unexported fields}FolderIterator manages a stream of *resourcemanagerpb.Folder.
func (*FolderIterator) All
func(it*FolderIterator)All()iter.Seq2[*resourcemanagerpb.Folder,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*FolderIterator) Next
func(it*FolderIterator)Next()(*resourcemanagerpb.Folder,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 (*FolderIterator) PageInfo
func(it*FolderIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
FoldersCallOptions
typeFoldersCallOptionsstruct{ListFolders[]gax.CallOptionSearchFolders[]gax.CallOptionGetFolder[]gax.CallOptionCreateFolder[]gax.CallOptionUpdateFolder[]gax.CallOptionMoveFolder[]gax.CallOptionDeleteFolder[]gax.CallOptionUndeleteFolder[]gax.CallOptionGetIamPolicy[]gax.CallOptionSetIamPolicy[]gax.CallOptionTestIamPermissions[]gax.CallOption}FoldersCallOptions contains the retry settings for each method of FoldersClient.
FoldersClient
typeFoldersClientstruct{// The call options for this service.CallOptions*FoldersCallOptions// 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}FoldersClient is a client for interacting with Cloud Resource Manager API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Manages Cloud Resource Folders.Cloud Resource Folders can be used to organize the resources under anorganization and to control the IAM policies applied to groups of resources.
func NewFoldersClient
funcNewFoldersClient(ctxcontext.Context,opts...option.ClientOption)(*FoldersClient,error)NewFoldersClient creates a new folders client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Manages Cloud Resource Folders.Cloud Resource Folders can be used to organize the resources under anorganization and to control the IAM policies applied to groups of resources.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewFoldersRESTClient
funcNewFoldersRESTClient(ctxcontext.Context,opts...option.ClientOption)(*FoldersClient,error)NewFoldersRESTClient creates a new folders rest client.
Manages Cloud Resource Folders.Cloud Resource Folders can be used to organize the resources under anorganization and to control the IAM policies applied to groups of resources.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2")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:=resourcemanager.NewFoldersRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*FoldersClient) Close
func(c*FoldersClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*FoldersClient) Connection (deprecated)
func(c*FoldersClient)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 (*FoldersClient) CreateFolder
func(c*FoldersClient)CreateFolder(ctxcontext.Context,req*resourcemanagerpb.CreateFolderRequest,opts...gax.CallOption)(*CreateFolderOperation,error)CreateFolder creates a Folder in the resource hierarchy.Returns an Operation which can be used to track the progress of thefolder creation workflow.Upon success the Operation.response field will be populated with thecreated Folder.
In order to succeed, the addition of this new Folder must not violatethe Folder naming, height or fanout constraints.
The Folder’s display_name must be distinct from all other Folder’s thatshare its parent.The addition of the Folder must not cause the active Folder hierarchyto exceed a height of 4. Note, the full active + deleted Folder hierarchyis allowed to reach a height of 8; this provides additional headroom whenmoving folders that contain deleted folders.The addition of the Folder must not cause the total number of Foldersunder its parent to exceed 100.If the operation fails due to a folder constraint violation, some errorsmay be returned by the CreateFolder request, with status codeFAILED_PRECONDITION and an error description. Other folder constraintviolations will be communicated in the Operation, with the specificPreconditionFailure returned via the details list in the Operation.errorfield.
The caller must have resourcemanager.folders.create permission on theidentified parent.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.CreateFolderRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#CreateFolderRequest.}op,err:=c.CreateFolder(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) CreateFolderOperation
func(c*FoldersClient)CreateFolderOperation(namestring)*CreateFolderOperationCreateFolderOperation returns a new CreateFolderOperation from a given name.The name must be that of a previously created CreateFolderOperation, possibly from a different process.
func (*FoldersClient) DeleteFolder
func(c*FoldersClient)DeleteFolder(ctxcontext.Context,req*resourcemanagerpb.DeleteFolderRequest,opts...gax.CallOption)(*resourcemanagerpb.Folder,error)DeleteFolder requests deletion of a Folder. The Folder is moved into theDELETE_REQUESTED stateimmediately, and is deleted approximately 30 days later. This method mayonly be called on an empty Folder in the[ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE (athttp://google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE)] state, where a Folder is empty ifit doesn’t contain any Folders or Projects in the[ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE (athttp://google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE)] state.The caller must have resourcemanager.folders.delete permission on theidentified folder.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.DeleteFolderRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#DeleteFolderRequest.}resp,err:=c.DeleteFolder(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) GetFolder
func(c*FoldersClient)GetFolder(ctxcontext.Context,req*resourcemanagerpb.GetFolderRequest,opts...gax.CallOption)(*resourcemanagerpb.Folder,error)GetFolder retrieves a Folder identified by the supplied resource name.Valid Folder resource names have the format folders/{folder_id}(for example, folders/1234).The caller must have resourcemanager.folders.get permission on theidentified folder.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.GetFolderRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#GetFolderRequest.}resp,err:=c.GetFolder(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) GetIamPolicy
func(c*FoldersClient)GetIamPolicy(ctxcontext.Context,req*iampb.GetIamPolicyRequest,opts...gax.CallOption)(*iampb.Policy,error)GetIamPolicy gets the access control policy for a Folder. The returned policy may beempty if no such policy or resource exists. The resource field shouldbe the Folder’s resource name, e.g. “folders/1234”.The caller must have resourcemanager.folders.getIamPolicy permissionon the identified folder.
Example
packagemainimport("context"iampb"cloud.google.com/go/iam/apiv1/iampb"resourcemanager"cloud.google.com/go/resourcemanager/apiv2")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.GetIamPolicyRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.}resp,err:=c.GetIamPolicy(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) ListFolders
func(c*FoldersClient)ListFolders(ctxcontext.Context,req*resourcemanagerpb.ListFoldersRequest,opts...gax.CallOption)*FolderIteratorListFolders lists the Folders that are direct descendants of supplied parent resource.List provides a strongly consistent view of the Folders underneaththe specified parent resource.List returns Folders sorted based upon the (ascending) lexical orderingof their display_name.The caller must have resourcemanager.folders.list permission on theidentified parent.
Examples
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb""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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.ListFoldersRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#ListFoldersRequest.}it:=c.ListFolders(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.(*resourcemanagerpb.ListFoldersResponse)}}all
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.ListFoldersRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#ListFoldersRequest.}forresp,err:=rangec.ListFolders(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*FoldersClient) MoveFolder
func(c*FoldersClient)MoveFolder(ctxcontext.Context,req*resourcemanagerpb.MoveFolderRequest,opts...gax.CallOption)(*MoveFolderOperation,error)MoveFolder moves a Folder under a new resource parent.Returns an Operation which can be used to track the progress of thefolder move workflow.Upon success the Operation.response field will be populated with themoved Folder.Upon failure, a FolderOperationError categorizing the failure cause willbe returned - if the failure occurs synchronously then theFolderOperationError will be returned via the Status.details fieldand if it occurs asynchronously then the FolderOperation will be returnedvia the Operation.error field.In addition, the Operation.metadata field will be populated with aFolderOperation message as an aid to stateless clients.Folder moves will be rejected if they violate either the naming, heightor fanout constraints described in theCreateFolder documentation.The caller must have resourcemanager.folders.move permission on thefolder’s current and proposed new parent.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.MoveFolderRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#MoveFolderRequest.}op,err:=c.MoveFolder(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) MoveFolderOperation
func(c*FoldersClient)MoveFolderOperation(namestring)*MoveFolderOperationMoveFolderOperation returns a new MoveFolderOperation from a given name.The name must be that of a previously created MoveFolderOperation, possibly from a different process.
func (*FoldersClient) SearchFolders
func(c*FoldersClient)SearchFolders(ctxcontext.Context,req*resourcemanagerpb.SearchFoldersRequest,opts...gax.CallOption)*FolderIteratorSearchFolders search for folders that match specific filter criteria.Search provides an eventually consistent view of the folders a user hasaccess to which meet the specified filter criteria.
This will only return folders on which the caller has thepermission resourcemanager.folders.get.
Examples
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb""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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.SearchFoldersRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#SearchFoldersRequest.}it:=c.SearchFolders(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.(*resourcemanagerpb.SearchFoldersResponse)}}all
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.SearchFoldersRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#SearchFoldersRequest.}forresp,err:=rangec.SearchFolders(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*FoldersClient) SetIamPolicy
func(c*FoldersClient)SetIamPolicy(ctxcontext.Context,req*iampb.SetIamPolicyRequest,opts...gax.CallOption)(*iampb.Policy,error)SetIamPolicy sets the access control policy on a Folder, replacing any existing policy.The resource field should be the Folder’s resource name, e.g.“folders/1234”.The caller must have resourcemanager.folders.setIamPolicy permissionon the identified folder.
Example
packagemainimport("context"iampb"cloud.google.com/go/iam/apiv1/iampb"resourcemanager"cloud.google.com/go/resourcemanager/apiv2")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.SetIamPolicyRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.}resp,err:=c.SetIamPolicy(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) TestIamPermissions
func(c*FoldersClient)TestIamPermissions(ctxcontext.Context,req*iampb.TestIamPermissionsRequest,opts...gax.CallOption)(*iampb.TestIamPermissionsResponse,error)TestIamPermissions returns permissions that a caller has on the specified Folder.The resource field should be the Folder’s resource name,e.g. “folders/1234”.
There are no permissions required for making this API call.
Example
packagemainimport("context"iampb"cloud.google.com/go/iam/apiv1/iampb"resourcemanager"cloud.google.com/go/resourcemanager/apiv2")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.TestIamPermissionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.}resp,err:=c.TestIamPermissions(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) UndeleteFolder
func(c*FoldersClient)UndeleteFolder(ctxcontext.Context,req*resourcemanagerpb.UndeleteFolderRequest,opts...gax.CallOption)(*resourcemanagerpb.Folder,error)UndeleteFolder cancels the deletion request for a Folder. This method may only becalled on a Folder in theDELETE_REQUESTED state.In order to succeed, the Folder’s parent must be in the[ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE (athttp://google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE)] state.In addition, reintroducing the folder into the tree must not violatefolder naming, height and fanout constraints described in theCreateFolder documentation.The caller must have resourcemanager.folders.undelete permission on theidentified folder.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.UndeleteFolderRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#UndeleteFolderRequest.}resp,err:=c.UndeleteFolder(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*FoldersClient) UpdateFolder
func(c*FoldersClient)UpdateFolder(ctxcontext.Context,req*resourcemanagerpb.UpdateFolderRequest,opts...gax.CallOption)(*resourcemanagerpb.Folder,error)UpdateFolder updates a Folder, changing its display_name.Changes to the folder display_name will be rejected if they violate eitherthe display_name formatting rules or naming constraints described inthe CreateFolder documentation.
The Folder’s display name must start and end with a letter or digit,may contain letters, digits, spaces, hyphens and underscores and can beno longer than 30 characters. This is captured by the regular expression:[\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.The caller must have resourcemanager.folders.update permission on theidentified folder.
If the update fails due to the unique name constraint then aPreconditionFailure explaining this violation will be returnedin the Status.details field.
Example
packagemainimport("context"resourcemanager"cloud.google.com/go/resourcemanager/apiv2"resourcemanagerpb"cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb")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:=resourcemanager.NewFoldersClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&resourcemanagerpb.UpdateFolderRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#UpdateFolderRequest.}resp,err:=c.UpdateFolder(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}MoveFolderOperation
typeMoveFolderOperationstruct{// contains filtered or unexported fields}MoveFolderOperation manages a long-running operation from MoveFolder.
func (*MoveFolderOperation) Done
func(op*MoveFolderOperation)Done()boolDone reports whether the long-running operation has completed.
func (*MoveFolderOperation) Metadata
func(op*MoveFolderOperation)Metadata()(*resourcemanagerpb.FolderOperation,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 (*MoveFolderOperation) Name
func(op*MoveFolderOperation)Name()stringName 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 (*MoveFolderOperation) Poll
func(op*MoveFolderOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*resourcemanagerpb.Folder,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 andthe 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 (*MoveFolderOperation) Wait
func(op*MoveFolderOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*resourcemanagerpb.Folder,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.
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.