{"modulePath":"github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries","version":"v0.0.0-20261019192026-b1dc9a900ccf","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package gce\n\nPackage gce is a lightweight testable wrapper around GCE compute APIs needed for the gcagent.\n\n## Types\n\n```go\ntype GCE struct {\n\t// contains filtered or unexported fields\n}\n```\nGCE is a wrapper for Google Compute Engine services.\n\n```go\nfunc NewGCEClient(ctx context.Context) (*GCE, error)\n```\nNewGCEClient creates a new GCE service wrapper.\n\n```go\nfunc (g *GCE) AddResourcePolicies(ctx context.Context, project, zone, diskName string, resourcePolicies []string) (*compute.Operation, error)\n```\nAddResourcePolicies adds the given resource policies of a disk.\n\n```go\nfunc (g *GCE) AttachDisk(ctx context.Context, diskName string, instanceName, project, dataDiskZone string) error\n```\nAttachDisk attaches the disk with the given name to the instance.\n\n```go\nfunc (g *GCE) CreateSnapshot(ctx context.Context, project string, snapshotReq *compute.Snapshot) (*compute.Operation, error)\n```\nCreateSnapshot creates a new standard snapshot.\n\n```go\nfunc (g *GCE) DeleteDisk(project, zone, disk string) (*compute.Operation, error)\n```\nDeleteDisk deletes a GCE Persistent Disk defined by the project, zone, and name provided.\n\n```go\nfunc (g *GCE) DetachDisk(ctx context.Context, instanceName, project, dataDiskZone, dataDiskName, dataDiskDeviceName string) error\n```\nDetachDisk detaches given disk from the instance.\n\n```go\nfunc (g *GCE) DiskAttachedToInstance(project, zone, instanceName, diskName string) (string, bool, error)\n```\nDiskAttachedToInstance returns the device name of the disk attached to the instance.\n\n```go\nfunc (g *GCE) GetAddress(project, location, name string) (*compute.Address, error)\n```\nGetAddress retrieves a GCE Address defined by the project, location, and name provided.\n\n```go\nfunc (g *GCE) GetAddressByIP(project, region, subnetwork, ip string) (*compute.Address, error)\n```\nGetAddressByIP attempts to find a ComputeAddress object with a given IP. The string is assumed to be an exact match, so a full IPv4 address is expected. A region should be supplied, or \"\" to search for a global address.\n\n```go\nfunc (g *GCE) GetDisk(project, zone, disk string) (*compute.Disk, error)\n```\nGetDisk retrieves a GCE Persistent Disk defined by the project zone and name provided.\n\n```go\nfunc (g *GCE) GetFilestore(project, zone, name string) (*file.Instance, error)\n```\nGetFilestore attempts to retrieve the filestore instance addressed by the provided project, location, and name.\n\n```go\nfunc (g *GCE) GetFilestoreByIP(project, location, ip string) (*file.ListInstancesResponse, error)\n```\nGetFilestoreByIP attempts to locate a GCE Filestore instance defined by the project, location, and IP Address provided.\n\n```go\nfunc (g *GCE) GetFilestoreInstance(project, location, filestore string) (*file.Instance, error)\n```\nGetFilestoreInstance retrieves a GCE Filestore Instance defined by the project, location, and name provided.\n\n```go\nfunc (g *GCE) GetForwardingRule(project, location, name string) (*compute.ForwardingRule, error)\n```\nGetForwardingRule retrieves a GCE Forwarding rule defined by the project, zone, and name provided.\n\n```go\nfunc (g *GCE) GetForwardingRuleByIP(project, ip string) (*compute.ForwardingRule, error)\n```\nGetForwardingRuleByIP retrieves a GCE Forwarding rule defined by the project, and IP address provided.\n\n```go\nfunc (g *GCE) GetHealthCheck(project, name string) (*compute.HealthCheck, error)\n```\nGetHealthCheck attempts to retrieve the compute HealthCheck object addressed by the provided project and name.\n\n```go\nfunc (g *GCE) GetInstance(project, zone, instance string) (*compute.Instance, error)\n```\nGetInstance retrieves a GCE Instance defined by the project, zone, and name provided.\n\n```go\nfunc (g *GCE) GetInstanceByIP(project, ip string) (*compute.Instance, error)\n```\nGetInstanceByIP retrieves a GCE Instance defined by the project, and IP provided. May return nil if an instance with the corresponding IP cannot be found.\n\n```go\nfunc (g *GCE) GetInstanceCPUAndMemorySize(ctx context.Context, project, zone, instanceName string) (int64, int64, error)\n```\nGetInstanceCPUAndMemorySize returns the CPU and memory size of the instance.\n\n```go\nfunc (g *GCE) GetInstanceGroup(project, zone, name string) (*compute.InstanceGroup, error)\n```\nGetInstanceGroup retrieves a GCE Instance Group rule defined by the project, zone, and name provided.\n\n```go\nfunc (g *GCE) GetNetwork(name, project string) (*compute.Network, error)\n```\nGetNetwork retrieves the network with the given name and project.\n\n```go\nfunc (g *GCE) GetRegionalBackendService(project, region, service string) (*compute.BackendService, error)\n```\nGetRegionalBackendService retrieves a GCE Backend Service defined by the project, region, and name provided.\n\n```go\nfunc (g *GCE) GetSecret(ctx context.Context, projectID, secretName string) (string, error)\n```\nGetSecret accesses the secret manager for the specified project ID and returns the stored password.\n\n```go\nfunc (g *GCE) GetSubnetwork(name, project, region string) (*compute.Subnetwork, error)\n```\nGetSubnetwork retrieves the subnetwork with the given name, project, and region.\n\n```go\nfunc (g *GCE) GetURIForIP(project, ip, region, subnetwork string) (string, error)\n```\nGetURIForIP attempts to locate the URI for any object that is related to the IP address provided.\n\n```go\nfunc (g *GCE) ListDisks(project, zone, filter string) (*compute.DiskList, error)\n```\nListDisks retrieves GCE Persistent Disks defined by the project, sone, and filter provided.\n\n```go\nfunc (g *GCE) ListInstanceGroupInstances(project, zone, name string) (*compute.InstanceGroupsListInstances, error)\n```\nListInstanceGroupInstances retrieves a list of GCE Instances in the Instance group defined by the project, zone, and name provided.\n\n```go\nfunc (g *GCE) ListSnapshots(ctx context.Context, project string) (*compute.SnapshotList, error)\n```\nListSnapshots lists the snapshots for a given project.\n\n```go\nfunc (g *GCE) ListZoneOperations(project, zone, filter string, maxResults int64) (*compute.OperationList, error)\n```\nListZoneOperations retrieves a list of Operations resources defined by the project, and zone provided. Results will be filtered according to the provided filter string, and limit the number of results to maxResults.\n\n```go\nfunc (g *GCE) OverrideComputeBasePath(basePath string)\n```\nOverrideComputeBasePath overrides the base path of the GCE clients.\n\n```go\nfunc (g *GCE) RemoveResourcePolicies(ctx context.Context, project, zone, diskName string, resourcePolicies []string) (*compute.Operation, error)\n```\nRemoveResourcePolicies removes the given resource policies of a disk.\n\n```go\nfunc (g *GCE) UpdateLabels(ctx context.Context, project, zone, diskName, labelFingerprint string, labels map[string]string) (*compute.Operation, error)\n```\nUpdateLabels sets the labels for a given disk.\n\n```go\nfunc (g *GCE) UpdateSnapshotLabels(ctx context.Context, project, snapshotName string, labels map[string]string) error\n```\nUpdateSnapshotLabels sets the labels for a given snapshot.\n\n```go\nfunc (g *GCE) WaitForDiskOpCompletionWithRetry(ctx context.Context, op *compute.Operation, project, dataDiskZone string) error\n```\nWaitForDiskOpCompletionWithRetry waits for the given compute operation to complete. We sleep for 120s between retries a total 10 times =\u003e max\\_wait\\_duration = 10\\*120 = 20 Minutes\n\n```go\nfunc (g *GCE) WaitForInstantSnapshotConversionCompletionWithRetry(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error\n```\nWaitForInstantSnapshotConversionCompletionWithRetry waits for the given compute operation to complete. We sleep for 30s between retries a total 480 times =\u003e max\\_wait\\_duration = 30\\*480 = 4 Hours\n\n```go\nfunc (g *GCE) WaitForSnapshotCreationCompletionWithRetry(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error\n```\nWaitForSnapshotCreationCompletionWithRetry waits for the given compute operation to complete. We sleep for 1s between retries a total 300 times =\u003e max\\_wait\\_duration = 5 minutes\n\n```go\nfunc (g *GCE) WaitForSnapshotUploadCompletionWithRetry(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error\n```\nWaitForSnapshotUploadCompletionWithRetry waits for the given compute operation to complete. We sleep for 30s between retries a total 480 times =\u003e max\\_wait\\_duration = 30\\*480 = 4 Hours\n\n","path":"github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries/gce","name":"gce","synopsis":"Package gce is a lightweight testable wrapper around GCE compute APIs needed for the gcagent.","isRedistributable":true}
