Cloud Shell API v1 - Package cloud.google.com/go/shell/apiv1 (v0.89.0)

Package shell is an auto-generated package for the Cloud Shell API.

Allows users to start, configure, and connect to interactive shell sessions running in the cloud.

Use of Context

The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

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

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

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

AddPublicKeyOperation

type AddPublicKeyOperation struct {
	// contains filtered or unexported fields
}

AddPublicKeyOperation manages a long-running operation from AddPublicKey.

func (*AddPublicKeyOperation) Done

func (op *AddPublicKeyOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*AddPublicKeyOperation) Metadata

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 (*AddPublicKeyOperation) Name

func (op *AddPublicKeyOperation) 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 (*AddPublicKeyOperation) Poll

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 (*AddPublicKeyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

AuthorizeEnvironmentOperation

type AuthorizeEnvironmentOperation struct {
	// contains filtered or unexported fields
}

AuthorizeEnvironmentOperation manages a long-running operation from AuthorizeEnvironment.

func (*AuthorizeEnvironmentOperation) Done

Done reports whether the long-running operation has completed.

func (*AuthorizeEnvironmentOperation) Metadata

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 (*AuthorizeEnvironmentOperation) Name

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 (*AuthorizeEnvironmentOperation) Poll

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 (*AuthorizeEnvironmentOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

CloudShellCallOptions

type CloudShellCallOptions struct {
	GetEnvironment       []gax.CallOption
	StartEnvironment     []gax.CallOption
	AuthorizeEnvironment []gax.CallOption
	AddPublicKey         []gax.CallOption
	RemovePublicKey      []gax.CallOption
}

CloudShellCallOptions contains the retry settings for each method of CloudShellClient.

CloudShellClient

type CloudShellClient struct {

	// The call options for this service.
	CallOptions *CloudShellCallOptions

	// 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
}

CloudShellClient is a client for interacting with Cloud Shell API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

API for interacting with Google Cloud Shell. Each user of Cloud Shell has at least one environment, which has the ID “default”. Environment consists of a Docker image defining what is installed on the environment and a home directory containing the user’s data that will remain across sessions. Clients use this API to start and fetch information about their environment, which can then be used to connect to that environment via a separate SSH client.

func NewCloudShellClient

func NewCloudShellClient(ctx context.Context, opts ...option.ClientOption) (*CloudShellClient, error)

NewCloudShellClient creates a new cloud shell service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

API for interacting with Google Cloud Shell. Each user of Cloud Shell has at least one environment, which has the ID “default”. Environment consists of a Docker image defining what is installed on the environment and a home directory containing the user’s data that will remain across sessions. Clients use this API to start and fetch information about their environment, which can then be used to connect to that environment via a separate SSH client.

Example

package main

import (
	"context"

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

func main() {
	ctx := context.Background()
	c, err := shell.NewCloudShellClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*CloudShellClient) AddPublicKey

AddPublicKey adds a public SSH key to an environment, allowing clients with the corresponding private key to connect to that environment via SSH. If a key with the same content already exists, this will error with ALREADY_EXISTS.

Example

package main

import (
	"context"

	shell "cloud.google.com/go/shell/apiv1"
	shellpb "google.golang.org/genproto/googleapis/cloud/shell/v1"
)

func main() {
	ctx := context.Background()
	c, err := shell.NewCloudShellClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &shellpb.AddPublicKeyRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.AddPublicKey(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*CloudShellClient) AddPublicKeyOperation

func (c *CloudShellClient) AddPublicKeyOperation(name string) *AddPublicKeyOperation

AddPublicKeyOperation returns a new AddPublicKeyOperation from a given name. The name must be that of a previously created AddPublicKeyOperation, possibly from a different process.

func (*CloudShellClient) AuthorizeEnvironment

AuthorizeEnvironment sends OAuth credentials to a running environment on behalf of a user. When this completes, the environment will be authorized to run various Google Cloud command line tools without requiring the user to manually authenticate.

Example

package main

import (
	"context"

	shell "cloud.google.com/go/shell/apiv1"
	shellpb "google.golang.org/genproto/googleapis/cloud/shell/v1"
)

func main() {
	ctx := context.Background()
	c, err := shell.NewCloudShellClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &shellpb.AuthorizeEnvironmentRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.AuthorizeEnvironment(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*CloudShellClient) AuthorizeEnvironmentOperation

func (c *CloudShellClient) AuthorizeEnvironmentOperation(name string) *AuthorizeEnvironmentOperation

AuthorizeEnvironmentOperation returns a new AuthorizeEnvironmentOperation from a given name. The name must be that of a previously created AuthorizeEnvironmentOperation, possibly from a different process.

func (*CloudShellClient) Close

func (c *CloudShellClient) Close() error

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

func (*CloudShellClient) Connection

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

Connection returns a connection to the API service.

Deprecated.

func (*CloudShellClient) GetEnvironment

GetEnvironment gets an environment. Returns NOT_FOUND if the environment does not exist.

Example

package main

import (
	"context"

	shell "cloud.google.com/go/shell/apiv1"
	shellpb "google.golang.org/genproto/googleapis/cloud/shell/v1"
)

func main() {
	ctx := context.Background()
	c, err := shell.NewCloudShellClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

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

func (*CloudShellClient) RemovePublicKey

RemovePublicKey removes a public SSH key from an environment. Clients will no longer be able to connect to the environment using the corresponding private key. If a key with the same content is not present, this will error with NOT_FOUND.

Example

package main

import (
	"context"

	shell "cloud.google.com/go/shell/apiv1"
	shellpb "google.golang.org/genproto/googleapis/cloud/shell/v1"
)

func main() {
	ctx := context.Background()
	c, err := shell.NewCloudShellClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &shellpb.RemovePublicKeyRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.RemovePublicKey(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*CloudShellClient) RemovePublicKeyOperation

func (c *CloudShellClient) RemovePublicKeyOperation(name string) *RemovePublicKeyOperation

RemovePublicKeyOperation returns a new RemovePublicKeyOperation from a given name. The name must be that of a previously created RemovePublicKeyOperation, possibly from a different process.

func (*CloudShellClient) StartEnvironment

StartEnvironment starts an existing environment, allowing clients to connect to it. The returned operation will contain an instance of StartEnvironmentMetadata in its metadata field. Users can wait for the environment to start by polling this operation via GetOperation. Once the environment has finished starting and is ready to accept connections, the operation will contain a StartEnvironmentResponse in its response field.

Example

package main

import (
	"context"

	shell "cloud.google.com/go/shell/apiv1"
	shellpb "google.golang.org/genproto/googleapis/cloud/shell/v1"
)

func main() {
	ctx := context.Background()
	c, err := shell.NewCloudShellClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &shellpb.StartEnvironmentRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.StartEnvironment(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*CloudShellClient) StartEnvironmentOperation

func (c *CloudShellClient) StartEnvironmentOperation(name string) *StartEnvironmentOperation

StartEnvironmentOperation returns a new StartEnvironmentOperation from a given name. The name must be that of a previously created StartEnvironmentOperation, possibly from a different process.

RemovePublicKeyOperation

type RemovePublicKeyOperation struct {
	// contains filtered or unexported fields
}

RemovePublicKeyOperation manages a long-running operation from RemovePublicKey.

func (*RemovePublicKeyOperation) Done

func (op *RemovePublicKeyOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*RemovePublicKeyOperation) Metadata

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 (*RemovePublicKeyOperation) Name

func (op *RemovePublicKeyOperation) 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 (*RemovePublicKeyOperation) Poll

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 (*RemovePublicKeyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

StartEnvironmentOperation

type StartEnvironmentOperation struct {
	// contains filtered or unexported fields
}

StartEnvironmentOperation manages a long-running operation from StartEnvironment.

func (*StartEnvironmentOperation) Done

func (op *StartEnvironmentOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*StartEnvironmentOperation) Metadata

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 (*StartEnvironmentOperation) Name

func (op *StartEnvironmentOperation) 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 (*StartEnvironmentOperation) Poll

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 (*StartEnvironmentOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.