package admin
import "cloud.google.com/go/datastore/admin/apiv1"
Package admin is an auto-generated package for the Cloud Datastore API.
Accesses the schemaless NoSQL database to provide fully managed, robust, scalable storage for your application.
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 := admin.NewDatastoreAdminClient(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 := admin.NewDatastoreAdminClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &adminpb.CreateIndexRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#CreateIndexRequest. } op, err := c.CreateIndex(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 NewDatastoreAdminClient 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 CreateIndexOperation
- func (op *CreateIndexOperation) Done() bool
- func (op *CreateIndexOperation) Metadata() (*adminpb.IndexOperationMetadata, error)
- func (op *CreateIndexOperation) Name() string
- func (op *CreateIndexOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, error)
- func (op *CreateIndexOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, error)
- type DatastoreAdminCallOptions
- type DatastoreAdminClient
- func NewDatastoreAdminClient(ctx context.Context, opts ...option.ClientOption) (*DatastoreAdminClient, error)
- func NewDatastoreAdminRESTClient(ctx context.Context, opts ...option.ClientOption) (*DatastoreAdminClient, error)
- func (c *DatastoreAdminClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error
- func (c *DatastoreAdminClient) Close() error
- func (c *DatastoreAdminClient) Connection() *grpc.ClientConn
- func (c *DatastoreAdminClient) CreateIndex(ctx context.Context, req *adminpb.CreateIndexRequest, opts ...gax.CallOption) (*CreateIndexOperation, error)
- func (c *DatastoreAdminClient) CreateIndexOperation(name string) *CreateIndexOperation
- func (c *DatastoreAdminClient) DeleteIndex(ctx context.Context, req *adminpb.DeleteIndexRequest, opts ...gax.CallOption) (*DeleteIndexOperation, error)
- func (c *DatastoreAdminClient) DeleteIndexOperation(name string) *DeleteIndexOperation
- func (c *DatastoreAdminClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error
- func (c *DatastoreAdminClient) ExportEntities(ctx context.Context, req *adminpb.ExportEntitiesRequest, opts ...gax.CallOption) (*ExportEntitiesOperation, error)
- func (c *DatastoreAdminClient) ExportEntitiesOperation(name string) *ExportEntitiesOperation
- func (c *DatastoreAdminClient) GetIndex(ctx context.Context, req *adminpb.GetIndexRequest, opts ...gax.CallOption) (*adminpb.Index, error)
- func (c *DatastoreAdminClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
- func (c *DatastoreAdminClient) ImportEntities(ctx context.Context, req *adminpb.ImportEntitiesRequest, opts ...gax.CallOption) (*ImportEntitiesOperation, error)
- func (c *DatastoreAdminClient) ImportEntitiesOperation(name string) *ImportEntitiesOperation
- func (c *DatastoreAdminClient) ListIndexes(ctx context.Context, req *adminpb.ListIndexesRequest, opts ...gax.CallOption) *IndexIterator
- func (c *DatastoreAdminClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
- type DeleteIndexOperation
- func (op *DeleteIndexOperation) Done() bool
- func (op *DeleteIndexOperation) Metadata() (*adminpb.IndexOperationMetadata, error)
- func (op *DeleteIndexOperation) Name() string
- func (op *DeleteIndexOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, error)
- func (op *DeleteIndexOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, error)
- type ExportEntitiesOperation
- func (op *ExportEntitiesOperation) Done() bool
- func (op *ExportEntitiesOperation) Metadata() (*adminpb.ExportEntitiesMetadata, error)
- func (op *ExportEntitiesOperation) Name() string
- func (op *ExportEntitiesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.ExportEntitiesResponse, error)
- func (op *ExportEntitiesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.ExportEntitiesResponse, error)
- type ImportEntitiesOperation
- func (op *ImportEntitiesOperation) Done() bool
- func (op *ImportEntitiesOperation) Metadata() (*adminpb.ImportEntitiesMetadata, error)
- func (op *ImportEntitiesOperation) Name() string
- func (op *ImportEntitiesOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
- func (op *ImportEntitiesOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
- type IndexIterator
- func (it *IndexIterator) All() iter.Seq2[*adminpb.Index, error]
- func (it *IndexIterator) Next() (*adminpb.Index, error)
- func (it *IndexIterator) PageInfo() *iterator.PageInfo
- type OperationIterator
Examples ¶
- DatastoreAdminClient.CancelOperation
- DatastoreAdminClient.CreateIndex
- DatastoreAdminClient.DeleteIndex
- DatastoreAdminClient.DeleteOperation
- DatastoreAdminClient.ExportEntities
- DatastoreAdminClient.GetIndex
- DatastoreAdminClient.GetOperation
- DatastoreAdminClient.ImportEntities
- DatastoreAdminClient.ListIndexes
- DatastoreAdminClient.ListIndexes (All)
- DatastoreAdminClient.ListOperations
- DatastoreAdminClient.ListOperations (All)
- NewDatastoreAdminClient
- NewDatastoreAdminRESTClient
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type CreateIndexOperation ¶
type CreateIndexOperation struct {
// contains filtered or unexported fields
}
CreateIndexOperation manages a long-running operation from CreateIndex.
func (*CreateIndexOperation) Done ¶
func (op *CreateIndexOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateIndexOperation) Metadata ¶
func (op *CreateIndexOperation) Metadata() (*adminpb.IndexOperationMetadata, 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 (*CreateIndexOperation) Name ¶
func (op *CreateIndexOperation) 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 (*CreateIndexOperation) Poll ¶
func (op *CreateIndexOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, 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 (*CreateIndexOperation) Wait ¶
func (op *CreateIndexOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, 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 DatastoreAdminCallOptions ¶
type DatastoreAdminCallOptions struct { ExportEntities []gax.CallOption ImportEntities []gax.CallOption CreateIndex []gax.CallOption DeleteIndex []gax.CallOption GetIndex []gax.CallOption ListIndexes []gax.CallOption CancelOperation []gax.CallOption DeleteOperation []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
DatastoreAdminCallOptions contains the retry settings for each method of DatastoreAdminClient.
type DatastoreAdminClient ¶
type DatastoreAdminClient struct { // The call options for this service. CallOptions *DatastoreAdminCallOptions // 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 }
DatastoreAdminClient is a client for interacting with Cloud Datastore API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Google Cloud Datastore Admin API
The Datastore Admin API provides several admin services for Cloud Datastore.
Concepts: Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.
Operation: An Operation represents work being performed in the background.
EntityFilter: Allows specifying a subset of entities in a project. This is specified as a combination of kinds and namespaces (either or both of which may be all).
Export/Import Service:
The Export/Import service provides the ability to copy all or a subset of entities to/from Google Cloud Storage. Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It is not restricted to the export source project. It is possible to export from one project and then import into another. Exported data can also be loaded into Google BigQuery for analysis. Exports and imports are performed asynchronously. An Operation resource is created for each export/import. The state (including any errors encountered) of the export/import may be queried via the Operation resource.
Index Service:
The index service manages Cloud Datastore composite indexes. Index creation and deletion are performed asynchronously. An Operation resource is created for each such asynchronous operation. The state of the operation (including any errors encountered) may be queried via the Operation resource.
Operation Service:
The Operations collection provides a record of actions performed for the specified project (including any operations in progress). Operations are not created directly but through calls on other collections or resources. An operation that is not yet done may be cancelled. The request to cancel is asynchronous and the operation may continue to run for some time after the request to cancel is made. An operation that is done may be deleted so that it is no longer listed as part of the Operation collection. ListOperations returns all pending operations, but not completed operations. Operations are created by service DatastoreAdmin, but are accessed via service google.longrunning.Operations.
func NewDatastoreAdminClient ¶
func NewDatastoreAdminClient(ctx context.Context, opts ...option.ClientOption) (*DatastoreAdminClient, error)
NewDatastoreAdminClient creates a new datastore admin client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Google Cloud Datastore Admin API
The Datastore Admin API provides several admin services for Cloud Datastore.
Concepts: Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.
Operation: An Operation represents work being performed in the background.
EntityFilter: Allows specifying a subset of entities in a project. This is specified as a combination of kinds and namespaces (either or both of which may be all).
Export/Import Service:
The Export/Import service provides the ability to copy all or a subset of entities to/from Google Cloud Storage. Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It is not restricted to the export source project. It is possible to export from one project and then import into another. Exported data can also be loaded into Google BigQuery for analysis. Exports and imports are performed asynchronously. An Operation resource is created for each export/import. The state (including any errors encountered) of the export/import may be queried via the Operation resource.
Index Service:
The index service manages Cloud Datastore composite indexes. Index creation and deletion are performed asynchronously. An Operation resource is created for each such asynchronous operation. The state of the operation (including any errors encountered) may be queried via the Operation resource.
Operation Service:
The Operations collection provides a record of actions performed for the specified project (including any operations in progress). Operations are not created directly but through calls on other collections or resources. An operation that is not yet done may be cancelled. The request to cancel is asynchronous and the operation may continue to run for some time after the request to cancel is made. An operation that is done may be deleted so that it is no longer listed as part of the Operation collection. ListOperations returns all pending operations, but not completed operations. Operations are created by service DatastoreAdmin, but are accessed via service google.longrunning.Operations.
Example¶
Code:play
package main import ( "context" admin "cloud.google.com/go/datastore/admin/apiv1" ) 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 := admin.NewDatastoreAdminClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
func NewDatastoreAdminRESTClient ¶
func NewDatastoreAdminRESTClient(ctx context.Context, opts ...option.ClientOption) (*DatastoreAdminClient, error)
NewDatastoreAdminRESTClient creates a new datastore admin rest client.
Google Cloud Datastore Admin API
The Datastore Admin API provides several admin services for Cloud Datastore.
Concepts: Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.
Operation: An Operation represents work being performed in the background.
EntityFilter: Allows specifying a subset of entities in a project. This is specified as a combination of kinds and namespaces (either or both of which may be all).
Export/Import Service:
The Export/Import service provides the ability to copy all or a subset of entities to/from Google Cloud Storage. Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It is not restricted to the export source project. It is possible to export from one project and then import into another. Exported data can also be loaded into Google BigQuery for analysis. Exports and imports are performed asynchronously. An Operation resource is created for each export/import. The state (including any errors encountered) of the export/import may be queried via the Operation resource.
Index Service:
The index service manages Cloud Datastore composite indexes. Index creation and deletion are performed asynchronously. An Operation resource is created for each such asynchronous operation. The state of the operation (including any errors encountered) may be queried via the Operation resource.
Operation Service:
The Operations collection provides a record of actions performed for the specified project (including any operations in progress). Operations are not created directly but through calls on other collections or resources. An operation that is not yet done may be cancelled. The request to cancel is asynchronous and the operation may continue to run for some time after the request to cancel is made. An operation that is done may be deleted so that it is no longer listed as part of the Operation collection. ListOperations returns all pending operations, but not completed operations. Operations are created by service DatastoreAdmin, but are accessed via service google.longrunning.Operations.
Example¶
Code:play
package main import ( "context" admin "cloud.google.com/go/datastore/admin/apiv1" ) 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 := admin.NewDatastoreAdminRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
func (*DatastoreAdminClient) CancelOperation ¶
func (c *DatastoreAdminClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error
CancelOperation is a utility method from google.longrunning.Operations.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.CancelOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
}
err = c.CancelOperation(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*DatastoreAdminClient) Close ¶
func (c *DatastoreAdminClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*DatastoreAdminClient) Connection ¶
func (c *DatastoreAdminClient) 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 (*DatastoreAdminClient) CreateIndex ¶
func (c *DatastoreAdminClient) CreateIndex(ctx context.Context, req *adminpb.CreateIndexRequest, opts ...gax.CallOption) (*CreateIndexOperation, error)
CreateIndex creates the specified index. A newly created index’s initial state is CREATING. On completion of the returned google.longrunning.Operation, the state will be READY. If the index already exists, the call will return an ALREADY_EXISTS status.
During index creation, the process could result in an error, in which case the index will move to the ERROR state. The process can be recovered by fixing the data that caused the error, removing the index with delete, then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
Indexes with a single property cannot be created.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
adminpb "cloud.google.com/go/datastore/admin/apiv1/adminpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &adminpb.CreateIndexRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#CreateIndexRequest.
}
op, err := c.CreateIndex(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DatastoreAdminClient) CreateIndexOperation ¶
func (c *DatastoreAdminClient) CreateIndexOperation(name string) *CreateIndexOperation
CreateIndexOperation returns a new CreateIndexOperation from a given name. The name must be that of a previously created CreateIndexOperation, possibly from a different process.
func (*DatastoreAdminClient) DeleteIndex ¶
func (c *DatastoreAdminClient) DeleteIndex(ctx context.Context, req *adminpb.DeleteIndexRequest, opts ...gax.CallOption) (*DeleteIndexOperation, error)
DeleteIndex deletes an existing index. An index can only be deleted if it is in a READY or ERROR state. On successful execution of the request, the index will be in a DELETING state. And on completion of the returned google.longrunning.Operation, the index will be removed.
During index deletion, the process could result in an error, in which
case the index will move to the ERROR state. The process can be recovered
by fixing the data that caused the error, followed by calling
delete again.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
adminpb "cloud.google.com/go/datastore/admin/apiv1/adminpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &adminpb.DeleteIndexRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#DeleteIndexRequest.
}
op, err := c.DeleteIndex(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DatastoreAdminClient) DeleteIndexOperation ¶
func (c *DatastoreAdminClient) DeleteIndexOperation(name string) *DeleteIndexOperation
DeleteIndexOperation returns a new DeleteIndexOperation from a given name. The name must be that of a previously created DeleteIndexOperation, possibly from a different process.
func (*DatastoreAdminClient) DeleteOperation ¶
func (c *DatastoreAdminClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error
DeleteOperation is a utility method from google.longrunning.Operations.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.DeleteOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
}
err = c.DeleteOperation(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*DatastoreAdminClient) ExportEntities ¶
func (c *DatastoreAdminClient) ExportEntities(ctx context.Context, req *adminpb.ExportEntitiesRequest, opts ...gax.CallOption) (*ExportEntitiesOperation, error)
ExportEntities exports a copy of all or a subset of entities from Google Cloud Datastore
to another storage system, such as Google Cloud Storage. Recent updates to
entities may not be reflected in the export. The export occurs in the
background and its progress can be monitored and managed via the
Operation resource that is created. The output of an export may only be
used once the associated operation is done. If an export operation is
cancelled before completion it may leave partial data behind in Google
Cloud Storage.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
adminpb "cloud.google.com/go/datastore/admin/apiv1/adminpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &adminpb.ExportEntitiesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#ExportEntitiesRequest.
}
op, err := c.ExportEntities(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DatastoreAdminClient) ExportEntitiesOperation ¶
func (c *DatastoreAdminClient) ExportEntitiesOperation(name string) *ExportEntitiesOperation
ExportEntitiesOperation returns a new ExportEntitiesOperation from a given name. The name must be that of a previously created ExportEntitiesOperation, possibly from a different process.
func (*DatastoreAdminClient) GetIndex ¶
func (c *DatastoreAdminClient) GetIndex(ctx context.Context, req *adminpb.GetIndexRequest, opts ...gax.CallOption) (*adminpb.Index, error)
GetIndex gets an index.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
adminpb "cloud.google.com/go/datastore/admin/apiv1/adminpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &adminpb.GetIndexRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#GetIndexRequest.
}
resp, err := c.GetIndex(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DatastoreAdminClient) GetOperation ¶
func (c *DatastoreAdminClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.GetOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
}
resp, err := c.GetOperation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DatastoreAdminClient) ImportEntities ¶
func (c *DatastoreAdminClient) ImportEntities(ctx context.Context, req *adminpb.ImportEntitiesRequest, opts ...gax.CallOption) (*ImportEntitiesOperation, error)
ImportEntities imports entities into Google Cloud Datastore. Existing entities with the
same key are overwritten. The import occurs in the background and its
progress can be monitored and managed via the Operation resource that is
created. If an ImportEntities operation is cancelled, it is possible
that a subset of the data has already been imported to Cloud Datastore.
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
adminpb "cloud.google.com/go/datastore/admin/apiv1/adminpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &adminpb.ImportEntitiesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#ImportEntitiesRequest.
}
op, err := c.ImportEntities(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DatastoreAdminClient) ImportEntitiesOperation ¶
func (c *DatastoreAdminClient) ImportEntitiesOperation(name string) *ImportEntitiesOperation
ImportEntitiesOperation returns a new ImportEntitiesOperation from a given name. The name must be that of a previously created ImportEntitiesOperation, possibly from a different process.
func (*DatastoreAdminClient) ListIndexes ¶
func (c *DatastoreAdminClient) ListIndexes(ctx context.Context, req *adminpb.ListIndexesRequest, opts ...gax.CallOption) *IndexIterator
ListIndexes lists the indexes that match the specified filters. Datastore uses an
eventually consistent query to fetch the list of indexes and may
occasionally return stale results.
Code:play
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
adminpb "cloud.google.com/go/datastore/admin/apiv1/adminpb"
"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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &adminpb.ListIndexesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#ListIndexesRequest.
}
it := c.ListIndexes(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.(*adminpb.ListIndexesResponse)
}
}
Example (All)¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
adminpb "cloud.google.com/go/datastore/admin/apiv1/adminpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &adminpb.ListIndexesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/datastore/admin/apiv1/adminpb#ListIndexesRequest.
}
for resp, err := range c.ListIndexes(ctx, req).All() {
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*DatastoreAdminClient) ListOperations ¶
func (c *DatastoreAdminClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Code:play
Code:play
Example¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
"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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.ListOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
}
it := c.ListOperations(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.(*longrunningpb.ListOperationsResponse)
}
}
Example (All)¶
package main
import (
"context"
admin "cloud.google.com/go/datastore/admin/apiv1"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
)
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 := admin.NewDatastoreAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.ListOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
}
for resp, err := range c.ListOperations(ctx, req).All() {
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
type DeleteIndexOperation ¶
type DeleteIndexOperation struct {
// contains filtered or unexported fields
}
DeleteIndexOperation manages a long-running operation from DeleteIndex.
func (*DeleteIndexOperation) Done ¶
func (op *DeleteIndexOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteIndexOperation) Metadata ¶
func (op *DeleteIndexOperation) Metadata() (*adminpb.IndexOperationMetadata, 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 (*DeleteIndexOperation) Name ¶
func (op *DeleteIndexOperation) 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 (*DeleteIndexOperation) Poll ¶
func (op *DeleteIndexOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, 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 (*DeleteIndexOperation) Wait ¶
func (op *DeleteIndexOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, 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 ExportEntitiesOperation ¶
type ExportEntitiesOperation struct {
// contains filtered or unexported fields
}
ExportEntitiesOperation manages a long-running operation from ExportEntities.
func (*ExportEntitiesOperation) Done ¶
func (op *ExportEntitiesOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*ExportEntitiesOperation) Metadata ¶
func (op *ExportEntitiesOperation) Metadata() (*adminpb.ExportEntitiesMetadata, 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 (*ExportEntitiesOperation) Name ¶
func (op *ExportEntitiesOperation) 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 (*ExportEntitiesOperation) Poll ¶
func (op *ExportEntitiesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.ExportEntitiesResponse, 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 (*ExportEntitiesOperation) Wait ¶
func (op *ExportEntitiesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.ExportEntitiesResponse, 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 ImportEntitiesOperation ¶
type ImportEntitiesOperation struct {
// contains filtered or unexported fields
}
ImportEntitiesOperation manages a long-running operation from ImportEntities.
func (*ImportEntitiesOperation) Done ¶
func (op *ImportEntitiesOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*ImportEntitiesOperation) Metadata ¶
func (op *ImportEntitiesOperation) Metadata() (*adminpb.ImportEntitiesMetadata, 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 (*ImportEntitiesOperation) Name ¶
func (op *ImportEntitiesOperation) 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 (*ImportEntitiesOperation) Poll ¶
func (op *ImportEntitiesOperation) Poll(ctx context.Context, opts ...gax.CallOption) 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 (*ImportEntitiesOperation) Wait ¶
func (op *ImportEntitiesOperation) Wait(ctx context.Context, opts ...gax.CallOption) 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 IndexIterator ¶
type IndexIterator 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 []*adminpb.Index, nextPageToken string, err error) // contains filtered or unexported fields }
IndexIterator manages a stream of *adminpb.Index.
func (*IndexIterator) All ¶
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*IndexIterator) Next ¶
func (it *IndexIterator) Next() (*adminpb.Index, 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 (*IndexIterator) PageInfo ¶
func (it *IndexIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type OperationIterator ¶
type OperationIterator 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 []*longrunningpb.Operation, nextPageToken string, err error) // contains filtered or unexported fields }
OperationIterator manages a stream of *longrunningpb.Operation.
func (*OperationIterator) All ¶
func (it *OperationIterator) All() iter.Seq2[*longrunningpb.Operation, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*OperationIterator) Next ¶
func (it *OperationIterator) Next() (*longrunningpb.Operation, 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 (*OperationIterator) PageInfo ¶
func (it *OperationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
Source Files ¶
auxiliary.go auxiliary_go123.go datastore_admin_client.go doc.go version.go
Directories ¶
Path | Synopsis |
---|---|
admin/apiv1/adminpb |
- Version
- v1.20.0 (latest)
- Published
- Oct 29, 2024
- Platform
- linux/amd64
- Imports
- 26 packages
- Last checked
- 7 hours ago –
Tools for package owners.