Class Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client (v0.4.5)

Client for the DatastoreAdmin service.

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).


Services

Export/Import

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

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

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.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the DatastoreAdmin Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all DatastoreAdmin clients
::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the DatastoreAdmin Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_index

def create_index(request, options = nil) -> ::Gapic::Operation
def create_index(project_id: nil, index: nil) -> ::Gapic::Operation

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.

Overloads
def create_index(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_index via a request object, either of type CreateIndexRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Datastore::Admin::V1::CreateIndexRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_index(project_id: nil, index: nil) -> ::Gapic::Operation
Pass arguments to create_index via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • project_id (::String) — Project ID against which to make the request.
  • index (::Google::Cloud::Datastore::Admin::V1::Index, ::Hash) — The index to create. The name and state fields are output only and will be ignored. Single property indexes cannot be created or deleted.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/datastore/admin/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Datastore::Admin::V1::CreateIndexRequest.new

# Call the create_index method.
result = client.create_index request

# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "Error!"
end

#delete_index

def delete_index(request, options = nil) -> ::Gapic::Operation
def delete_index(project_id: nil, index_id: nil) -> ::Gapic::Operation

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.

Overloads
def delete_index(request, options = nil) -> ::Gapic::Operation
Pass arguments to delete_index via a request object, either of type Google::Cloud::Datastore::Admin::V1::DeleteIndexRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Datastore::Admin::V1::DeleteIndexRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_index(project_id: nil, index_id: nil) -> ::Gapic::Operation
Pass arguments to delete_index via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • project_id (::String) — Project ID against which to make the request.
  • index_id (::String) — The resource ID of the index to delete.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/datastore/admin/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Datastore::Admin::V1::DeleteIndexRequest.new

# Call the delete_index method.
result = client.delete_index request

# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "Error!"
end

#export_entities

def export_entities(request, options = nil) -> ::Gapic::Operation
def export_entities(project_id: nil, labels: nil, entity_filter: nil, output_url_prefix: nil) -> ::Gapic::Operation

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.

Overloads
def export_entities(request, options = nil) -> ::Gapic::Operation
Pass arguments to export_entities via a request object, either of type ExportEntitiesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Datastore::Admin::V1::ExportEntitiesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def export_entities(project_id: nil, labels: nil, entity_filter: nil, output_url_prefix: nil) -> ::Gapic::Operation
Pass arguments to export_entities via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • project_id (::String) — Required. Project ID against which to make the request.
  • labels (::Hash{::String => ::String}) — Client-assigned labels.
  • entity_filter (::Google::Cloud::Datastore::Admin::V1::EntityFilter, ::Hash) — Description of what data from the project is included in the export.
  • output_url_prefix (::String) — Required. Location for the export metadata and data files.

    The full resource URL of the external storage location. Currently, only Google Cloud Storage is supported. So output_url_prefix should be of the form: gs://BUCKET_NAME[/NAMESPACE_PATH], where BUCKET_NAME is the name of the Cloud Storage bucket and NAMESPACE_PATH is an optional Cloud Storage namespace path (this is not a Cloud Datastore namespace). For more information about Cloud Storage namespace paths, see Object name considerations.

    The resulting files will be nested deeper than the specified URL prefix. The final output URL will be provided in the google.datastore.admin.v1.ExportEntitiesResponse.output_url field. That value should be used for subsequent ImportEntities operations.

    By nesting the data files deeper, the same Cloud Storage bucket can be used in multiple ExportEntities operations without conflict.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/datastore/admin/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Datastore::Admin::V1::ExportEntitiesRequest.new

# Call the export_entities method.
result = client.export_entities request

# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "Error!"
end

#get_index

def get_index(request, options = nil) -> ::Google::Cloud::Datastore::Admin::V1::Index
def get_index(project_id: nil, index_id: nil) -> ::Google::Cloud::Datastore::Admin::V1::Index

Gets an index.

Overloads
def get_index(request, options = nil) -> ::Google::Cloud::Datastore::Admin::V1::Index
Pass arguments to get_index via a request object, either of type GetIndexRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Datastore::Admin::V1::GetIndexRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_index(project_id: nil, index_id: nil) -> ::Google::Cloud::Datastore::Admin::V1::Index
Pass arguments to get_index via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • project_id (::String) — Project ID against which to make the request.
  • index_id (::String) — The resource ID of the index to get.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/datastore/admin/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Datastore::Admin::V1::GetIndexRequest.new

# Call the get_index method.
result = client.get_index request

# The returned object is of type Google::Cloud::Datastore::Admin::V1::Index.
p result

#import_entities

def import_entities(request, options = nil) -> ::Gapic::Operation
def import_entities(project_id: nil, labels: nil, input_url: nil, entity_filter: nil) -> ::Gapic::Operation

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.

Overloads
def import_entities(request, options = nil) -> ::Gapic::Operation
Pass arguments to import_entities via a request object, either of type ImportEntitiesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Datastore::Admin::V1::ImportEntitiesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def import_entities(project_id: nil, labels: nil, input_url: nil, entity_filter: nil) -> ::Gapic::Operation
Pass arguments to import_entities via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • project_id (::String) — Required. Project ID against which to make the request.
  • labels (::Hash{::String => ::String}) — Client-assigned labels.
  • input_url (::String) — Required. The full resource URL of the external storage location. Currently, only Google Cloud Storage is supported. So input_url should be of the form: gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE, where BUCKET_NAME is the name of the Cloud Storage bucket, NAMESPACE_PATH is an optional Cloud Storage namespace path (this is not a Cloud Datastore namespace), and OVERALL_EXPORT_METADATA_FILE is the metadata file written by the ExportEntities operation. For more information about Cloud Storage namespace paths, see Object name considerations.

    For more information, see google.datastore.admin.v1.ExportEntitiesResponse.output_url.

  • entity_filter (::Google::Cloud::Datastore::Admin::V1::EntityFilter, ::Hash) — Optionally specify which kinds/namespaces are to be imported. If provided, the list must be a subset of the EntityFilter used in creating the export, otherwise a FAILED_PRECONDITION error will be returned. If no filter is specified then all entities from the export are imported.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/datastore/admin/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Datastore::Admin::V1::ImportEntitiesRequest.new

# Call the import_entities method.
result = client.import_entities request

# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "Error!"
end

#initialize

def initialize() { |config| ... } -> Client

Create a new DatastoreAdmin client object.

Yields
  • (config) — Configure the DatastoreAdmin client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new do |config|
  config.timeout = 10.0
end

#list_indexes

def list_indexes(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Datastore::Admin::V1::Index>
def list_indexes(project_id: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Datastore::Admin::V1::Index>

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.

Overloads
def list_indexes(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Datastore::Admin::V1::Index>
Pass arguments to list_indexes via a request object, either of type ListIndexesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Datastore::Admin::V1::ListIndexesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_indexes(project_id: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Datastore::Admin::V1::Index>
Pass arguments to list_indexes via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • project_id (::String) — Project ID against which to make the request.
  • filter (::String)
  • page_size (::Integer) — The maximum number of items to return. If zero, then all results will be returned.
  • page_token (::String) — The next_page_token value returned from a previous List request, if any.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/datastore/admin/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Datastore::Admin::V1::ListIndexesRequest.new

# Call the list_indexes method.
result = client.list_indexes request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Datastore::Admin::V1::Index.
  p response
end

#operations_client

def operations_client() -> ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Operations

Get the associated client for long-running operations.