Documentation ¶
Overview ¶
Package resourcemanager is an auto-generated package for the Cloud Resource Manager API.
Creates, reads, and updates metadata for Google Cloud Platform resource containers.
General documentation ¶
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage ¶
To get started with this package, create a client.
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 := resourcemanager.NewFoldersClient(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.
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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) 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 NewFoldersClient 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 ¶
- func DefaultAuthScopes() []string
- type CreateFolderOperation
- func (op *CreateFolderOperation) Done() bool
- func (op *CreateFolderOperation) Metadata() (*resourcemanagerpb.FolderOperation, error)
- func (op *CreateFolderOperation) Name() string
- func (op *CreateFolderOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*resourcemanagerpb.Folder, error)
- func (op *CreateFolderOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*resourcemanagerpb.Folder, error)
- type FolderIterator
- type FoldersCallOptions
- type FoldersClient
- func (c *FoldersClient) Close() error
- func (c *FoldersClient) Connection() *grpc.ClientConndeprecated
- func (c *FoldersClient) CreateFolder(ctx context.Context, req *resourcemanagerpb.CreateFolderRequest, ...) (*CreateFolderOperation, error)
- func (c *FoldersClient) CreateFolderOperation(name string) *CreateFolderOperation
- func (c *FoldersClient) DeleteFolder(ctx context.Context, req *resourcemanagerpb.DeleteFolderRequest, ...) (*resourcemanagerpb.Folder, error)
- func (c *FoldersClient) GetFolder(ctx context.Context, req *resourcemanagerpb.GetFolderRequest, ...) (*resourcemanagerpb.Folder, error)
- func (c *FoldersClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *FoldersClient) ListFolders(ctx context.Context, req *resourcemanagerpb.ListFoldersRequest, ...) *FolderIterator
- func (c *FoldersClient) MoveFolder(ctx context.Context, req *resourcemanagerpb.MoveFolderRequest, ...) (*MoveFolderOperation, error)
- func (c *FoldersClient) MoveFolderOperation(name string) *MoveFolderOperation
- func (c *FoldersClient) SearchFolders(ctx context.Context, req *resourcemanagerpb.SearchFoldersRequest, ...) *FolderIterator
- func (c *FoldersClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *FoldersClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, ...) (*iampb.TestIamPermissionsResponse, error)
- func (c *FoldersClient) UndeleteFolder(ctx context.Context, req *resourcemanagerpb.UndeleteFolderRequest, ...) (*resourcemanagerpb.Folder, error)
- func (c *FoldersClient) UpdateFolder(ctx context.Context, req *resourcemanagerpb.UpdateFolderRequest, ...) (*resourcemanagerpb.Folder, error)
- type MoveFolderOperation
- func (op *MoveFolderOperation) Done() bool
- func (op *MoveFolderOperation) Metadata() (*resourcemanagerpb.FolderOperation, error)
- func (op *MoveFolderOperation) Name() string
- func (op *MoveFolderOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*resourcemanagerpb.Folder, error)
- func (op *MoveFolderOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*resourcemanagerpb.Folder, error)
Examples ¶
- FoldersClient.CreateFolder
- FoldersClient.DeleteFolder
- FoldersClient.GetFolder
- FoldersClient.GetIamPolicy
- FoldersClient.ListFolders
- FoldersClient.ListFolders (All)
- FoldersClient.MoveFolder
- FoldersClient.SearchFolders
- FoldersClient.SearchFolders (All)
- FoldersClient.SetIamPolicy
- FoldersClient.TestIamPermissions
- FoldersClient.UndeleteFolder
- FoldersClient.UpdateFolder
- NewFoldersClient
- NewFoldersRESTClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type CreateFolderOperation ¶
type CreateFolderOperation struct {
// contains filtered or unexported fields
}
CreateFolderOperation manages a long-running operation from CreateFolder.
func (*CreateFolderOperation) Done ¶
func (op *CreateFolderOperation) Done() bool
Done 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() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateFolderOperation) Poll ¶
func (op *CreateFolderOperation) Poll(ctx context.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 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 (*CreateFolderOperation) Wait ¶
func (op *CreateFolderOperation) Wait(ctx context.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.
type FolderIterator ¶
type FolderIterator 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 []*resourcemanagerpb.Folder, nextPageToken string, err error) // contains filtered or unexported fields }
FolderIterator manages a stream of *resourcemanagerpb.Folder.
func (*FolderIterator) All ¶ added in v1.10.1
func (it *FolderIterator) All() iter.Seq2[*resourcemanagerpb.Folder, error]
All returns an iterator. If an error is returned by the iterator, the iterator 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 more results. Once Next returns Done, all subsequent calls will return Done.
func (*FolderIterator) PageInfo ¶
func (it *FolderIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type FoldersCallOptions ¶
type FoldersCallOptions struct { ListFolders []gax.CallOption SearchFolders []gax.CallOption GetFolder []gax.CallOption CreateFolder []gax.CallOption UpdateFolder []gax.CallOption MoveFolder []gax.CallOption DeleteFolder []gax.CallOption UndeleteFolder []gax.CallOption GetIamPolicy []gax.CallOption SetIamPolicy []gax.CallOption TestIamPermissions []gax.CallOption }
FoldersCallOptions contains the retry settings for each method of FoldersClient.
type FoldersClient ¶
type FoldersClient struct { // 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 an organization and to control the IAM policies applied to groups of resources.
func NewFoldersClient ¶
func NewFoldersClient(ctx context.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 an organization and to control the IAM policies applied to groups of resources.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewFoldersRESTClient ¶ added in v1.5.0
func NewFoldersRESTClient(ctx context.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 an organization and to control the IAM policies applied to groups of resources.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" ) 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 := resourcemanager.NewFoldersRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*FoldersClient) Close ¶
func (c *FoldersClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*FoldersClient) Connection
deprecated
func (c *FoldersClient) 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 (*FoldersClient) CreateFolder ¶
func (c *FoldersClient) CreateFolder(ctx context.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 the folder creation workflow. Upon success the Operation.response field will be populated with the created Folder.
In order to succeed, the addition of this new Folder must not violate the Folder naming, height or fanout constraints.
The Folder’s display_name must be distinct from all other Folder’s that share its parent. The addition of the Folder must not cause the active Folder hierarchy to exceed a height of 4. Note, the full active + deleted Folder hierarchy is allowed to reach a height of 8; this provides additional headroom when moving folders that contain deleted folders. The addition of the Folder must not cause the total number of Folders under its parent to exceed 100.
If the operation fails due to a folder constraint violation, some errors may be returned by the CreateFolder request, with status code FAILED_PRECONDITION and an error description. Other folder constraint violations will be communicated in the Operation, with the specific PreconditionFailure returned via the details list in the Operation.error field.
The caller must have resourcemanager.folders.create permission on the identified parent.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) CreateFolderOperation ¶
func (c *FoldersClient) CreateFolderOperation(name string) *CreateFolderOperation
CreateFolderOperation 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(ctx context.Context, req *resourcemanagerpb.DeleteFolderRequest, opts ...gax.CallOption) (*resourcemanagerpb.Folder, error)
DeleteFolder requests deletion of a Folder. The Folder is moved into the DELETE_REQUESTED state immediately, and is deleted approximately 30 days later. This method may only be called on an empty Folder in the [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE (at http://google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE)] state, where a Folder is empty if it doesn’t contain any Folders or Projects in the [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE (at http://google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE)] state. The caller must have resourcemanager.folders.delete permission on the identified folder.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) GetFolder ¶
func (c *FoldersClient) GetFolder(ctx context.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 the identified folder.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) GetIamPolicy ¶
func (c *FoldersClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
GetIamPolicy gets the access control policy for a Folder. The returned policy may be empty if no such policy or resource exists. The resource field should be the Folder’s resource name, e.g. “folders/1234”. The caller must have resourcemanager.folders.getIamPolicy permission on the identified folder.
Example ¶
package main import ( "context" iampb "cloud.google.com/go/iam/apiv1/iampb" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) ListFolders ¶
func (c *FoldersClient) ListFolders(ctx context.Context, req *resourcemanagerpb.ListFoldersRequest, opts ...gax.CallOption) *FolderIterator
ListFolders lists the Folders that are direct descendants of supplied parent resource. List provides a strongly consistent view of the Folders underneath the specified parent resource. List returns Folders sorted based upon the (ascending) lexical ordering of their display_name. The caller must have resourcemanager.folders.list permission on the identified parent.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" "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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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() 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.(*resourcemanagerpb.ListFoldersResponse) } }
Output:
Example (All) ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &resourcemanagerpb.ListFoldersRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#ListFoldersRequest. } for resp, err := range c.ListFolders(ctx, req).All() { if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*FoldersClient) MoveFolder ¶
func (c *FoldersClient) MoveFolder(ctx context.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 the folder move workflow. Upon success the Operation.response field will be populated with the moved Folder. Upon failure, a FolderOperationError categorizing the failure cause will be returned - if the failure occurs synchronously then the FolderOperationError will be returned via the Status.details field and if it occurs asynchronously then the FolderOperation will be returned via the Operation.error field. In addition, the Operation.metadata field will be populated with a FolderOperation message as an aid to stateless clients. Folder moves will be rejected if they violate either the naming, height or fanout constraints described in the CreateFolder documentation. The caller must have resourcemanager.folders.move permission on the folder’s current and proposed new parent.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) MoveFolderOperation ¶
func (c *FoldersClient) MoveFolderOperation(name string) *MoveFolderOperation
MoveFolderOperation 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(ctx context.Context, req *resourcemanagerpb.SearchFoldersRequest, opts ...gax.CallOption) *FolderIterator
SearchFolders search for folders that match specific filter criteria. Search provides an eventually consistent view of the folders a user has access to which meet the specified filter criteria.
This will only return folders on which the caller has the permission resourcemanager.folders.get.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" "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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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() 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.(*resourcemanagerpb.SearchFoldersResponse) } }
Output:
Example (All) ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &resourcemanagerpb.SearchFoldersRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb#SearchFoldersRequest. } for resp, err := range c.SearchFolders(ctx, req).All() { if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*FoldersClient) SetIamPolicy ¶
func (c *FoldersClient) SetIamPolicy(ctx context.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 permission on the identified folder.
Example ¶
package main import ( "context" iampb "cloud.google.com/go/iam/apiv1/iampb" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) TestIamPermissions ¶
func (c *FoldersClient) TestIamPermissions(ctx context.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 ¶
package main import ( "context" iampb "cloud.google.com/go/iam/apiv1/iampb" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) UndeleteFolder ¶
func (c *FoldersClient) UndeleteFolder(ctx context.Context, req *resourcemanagerpb.UndeleteFolderRequest, opts ...gax.CallOption) (*resourcemanagerpb.Folder, error)
UndeleteFolder cancels the deletion request for a Folder. This method may only be called on a Folder in the DELETE_REQUESTED state. In order to succeed, the Folder’s parent must be in the [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE (at http://google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE)] state. In addition, reintroducing the folder into the tree must not violate folder naming, height and fanout constraints described in the CreateFolder documentation. The caller must have resourcemanager.folders.undelete permission on the identified folder.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FoldersClient) UpdateFolder ¶
func (c *FoldersClient) UpdateFolder(ctx context.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 either the display_name formatting rules or naming constraints described in the 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 be no 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 the identified folder.
If the update fails due to the unique name constraint then a PreconditionFailure explaining this violation will be returned in the Status.details field.
Example ¶
package main import ( "context" resourcemanager "cloud.google.com/go/resourcemanager/apiv2" resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv2/resourcemanagerpb" ) 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 := resourcemanager.NewFoldersClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type MoveFolderOperation ¶
type MoveFolderOperation struct {
// contains filtered or unexported fields
}
MoveFolderOperation manages a long-running operation from MoveFolder.
func (*MoveFolderOperation) Done ¶
func (op *MoveFolderOperation) Done() bool
Done 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() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*MoveFolderOperation) Poll ¶
func (op *MoveFolderOperation) Poll(ctx context.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 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 (*MoveFolderOperation) Wait ¶
func (op *MoveFolderOperation) Wait(ctx context.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.