package shell
import "cloud.google.com/go/shell/apiv1"
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.
Index ¶
- func DefaultAuthScopes() []string
- type AddPublicKeyOperation
- func (op *AddPublicKeyOperation) Done() bool
- func (op *AddPublicKeyOperation) Metadata() (*shellpb.AddPublicKeyMetadata, error)
- func (op *AddPublicKeyOperation) Name() string
- func (op *AddPublicKeyOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.AddPublicKeyResponse, error)
- func (op *AddPublicKeyOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.AddPublicKeyResponse, error)
- type AuthorizeEnvironmentOperation
- func (op *AuthorizeEnvironmentOperation) Done() bool
- func (op *AuthorizeEnvironmentOperation) Metadata() (*shellpb.AuthorizeEnvironmentMetadata, error)
- func (op *AuthorizeEnvironmentOperation) Name() string
- func (op *AuthorizeEnvironmentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.AuthorizeEnvironmentResponse, error)
- func (op *AuthorizeEnvironmentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.AuthorizeEnvironmentResponse, error)
- type CloudShellCallOptions
- type CloudShellClient
- func NewCloudShellClient(ctx context.Context, opts ...option.ClientOption) (*CloudShellClient, error)
- func (c *CloudShellClient) AddPublicKey(ctx context.Context, req *shellpb.AddPublicKeyRequest, opts ...gax.CallOption) (*AddPublicKeyOperation, error)
- func (c *CloudShellClient) AddPublicKeyOperation(name string) *AddPublicKeyOperation
- func (c *CloudShellClient) AuthorizeEnvironment(ctx context.Context, req *shellpb.AuthorizeEnvironmentRequest, opts ...gax.CallOption) (*AuthorizeEnvironmentOperation, error)
- func (c *CloudShellClient) AuthorizeEnvironmentOperation(name string) *AuthorizeEnvironmentOperation
- func (c *CloudShellClient) Close() error
- func (c *CloudShellClient) Connection() *grpc.ClientConn
- func (c *CloudShellClient) GetEnvironment(ctx context.Context, req *shellpb.GetEnvironmentRequest, opts ...gax.CallOption) (*shellpb.Environment, error)
- func (c *CloudShellClient) RemovePublicKey(ctx context.Context, req *shellpb.RemovePublicKeyRequest, opts ...gax.CallOption) (*RemovePublicKeyOperation, error)
- func (c *CloudShellClient) RemovePublicKeyOperation(name string) *RemovePublicKeyOperation
- func (c *CloudShellClient) StartEnvironment(ctx context.Context, req *shellpb.StartEnvironmentRequest, opts ...gax.CallOption) (*StartEnvironmentOperation, error)
- func (c *CloudShellClient) StartEnvironmentOperation(name string) *StartEnvironmentOperation
- type RemovePublicKeyOperation
- func (op *RemovePublicKeyOperation) Done() bool
- func (op *RemovePublicKeyOperation) Metadata() (*shellpb.RemovePublicKeyMetadata, error)
- func (op *RemovePublicKeyOperation) Name() string
- func (op *RemovePublicKeyOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.RemovePublicKeyResponse, error)
- func (op *RemovePublicKeyOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.RemovePublicKeyResponse, error)
- type StartEnvironmentOperation
- func (op *StartEnvironmentOperation) Done() bool
- func (op *StartEnvironmentOperation) Metadata() (*shellpb.StartEnvironmentMetadata, error)
- func (op *StartEnvironmentOperation) Name() string
- func (op *StartEnvironmentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.StartEnvironmentResponse, error)
- func (op *StartEnvironmentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.StartEnvironmentResponse, error)
Examples ¶
- CloudShellClient.AddPublicKey
- CloudShellClient.AuthorizeEnvironment
- CloudShellClient.GetEnvironment
- CloudShellClient.RemovePublicKey
- CloudShellClient.StartEnvironment
- NewCloudShellClient
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type 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 ¶
func (op *AddPublicKeyOperation) Metadata() (*shellpb.AddPublicKeyMetadata, 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 (*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 ¶
func (op *AddPublicKeyOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.AddPublicKeyResponse, 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 (*AddPublicKeyOperation) Wait ¶
func (op *AddPublicKeyOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.AddPublicKeyResponse, 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 AuthorizeEnvironmentOperation ¶
type AuthorizeEnvironmentOperation struct {
// contains filtered or unexported fields
}
AuthorizeEnvironmentOperation manages a long-running operation from AuthorizeEnvironment.
func (*AuthorizeEnvironmentOperation) Done ¶
func (op *AuthorizeEnvironmentOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*AuthorizeEnvironmentOperation) Metadata ¶
func (op *AuthorizeEnvironmentOperation) Metadata() (*shellpb.AuthorizeEnvironmentMetadata, 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 (*AuthorizeEnvironmentOperation) Name ¶
func (op *AuthorizeEnvironmentOperation) 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 (*AuthorizeEnvironmentOperation) Poll ¶
func (op *AuthorizeEnvironmentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.AuthorizeEnvironmentResponse, 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 (*AuthorizeEnvironmentOperation) Wait ¶
func (op *AuthorizeEnvironmentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.AuthorizeEnvironmentResponse, 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 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.
type 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.
func (*CloudShellClient) AddPublicKey ¶
func (c *CloudShellClient) AddPublicKey(ctx context.Context, req *shellpb.AddPublicKeyRequest, opts ...gax.CallOption) (*AddPublicKeyOperation, error)
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.
Code:play
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 ¶
func (c *CloudShellClient) AuthorizeEnvironment(ctx context.Context, req *shellpb.AuthorizeEnvironmentRequest, opts ...gax.CallOption) (*AuthorizeEnvironmentOperation, error)
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.
Code:play
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 ¶
func (c *CloudShellClient) GetEnvironment(ctx context.Context, req *shellpb.GetEnvironmentRequest, opts ...gax.CallOption) (*shellpb.Environment, error)
GetEnvironment gets an environment. Returns NOT_FOUND if the environment does not exist.
Code:play
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 ¶
func (c *CloudShellClient) RemovePublicKey(ctx context.Context, req *shellpb.RemovePublicKeyRequest, opts ...gax.CallOption) (*RemovePublicKeyOperation, error)
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.
Code:play
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 ¶
func (c *CloudShellClient) StartEnvironment(ctx context.Context, req *shellpb.StartEnvironmentRequest, opts ...gax.CallOption) (*StartEnvironmentOperation, error)
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.
Code:play
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.
type 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 ¶
func (op *RemovePublicKeyOperation) Metadata() (*shellpb.RemovePublicKeyMetadata, 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 (*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 ¶
func (op *RemovePublicKeyOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.RemovePublicKeyResponse, 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 (*RemovePublicKeyOperation) Wait ¶
func (op *RemovePublicKeyOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.RemovePublicKeyResponse, 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 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 ¶
func (op *StartEnvironmentOperation) Metadata() (*shellpb.StartEnvironmentMetadata, 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 (*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 ¶
func (op *StartEnvironmentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*shellpb.StartEnvironmentResponse, 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 (*StartEnvironmentOperation) Wait ¶
func (op *StartEnvironmentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*shellpb.StartEnvironmentResponse, 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.
Source Files ¶
cloud_shell_client.go doc.go
- Version
- v0.87.0
- Published
- Jul 13, 2021
- Platform
- windows/amd64
- Imports
- 21 packages
- Last checked
- 25 minutes ago –
Tools for package owners.