/// <summary>Snippet for ExportEntities</summary> public void ExportEntitiesRequestObject() { // Snippet: ExportEntities(ExportEntitiesRequest, CallSettings) // Create client DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.Create(); // Initialize request argument(s) ExportEntitiesRequest request = new ExportEntitiesRequest { ProjectId = "", Labels = { { "", "" }, }, EntityFilter = new EntityFilter(), OutputUrlPrefix = "", }; // Make the request Operation <ExportEntitiesResponse, ExportEntitiesMetadata> response = datastoreAdminClient.ExportEntities(request); // Poll until the returned long-running operation is complete Operation <ExportEntitiesResponse, ExportEntitiesMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result ExportEntitiesResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <ExportEntitiesResponse, ExportEntitiesMetadata> retrievedResponse = datastoreAdminClient.PollOnceExportEntities(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result ExportEntitiesResponse retrievedResult = retrievedResponse.Result; } // End snippet }
public string ExportEntities( string projectId = "your-project-id", string outputUrlPrefix = "gs://your-bucket-name", string kind = "Task", string namespaceId = "default") { // [START datastore_admin_client_create] // Create client DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.Create(); // [END datastore_admin_client_create] IDictionary <string, string> labels = new Dictionary <string, string> { { "cloud_datastore_samples", "true" }, }; EntityFilter entityFilter = new EntityFilter { Kinds = { kind }, NamespaceIds = { namespaceId } }; var response = datastoreAdminClient.ExportEntities(projectId, labels, entityFilter, outputUrlPrefix); // Poll until the returned long-running operation is complete var completedResponse = response.PollUntilCompleted(); if (completedResponse.IsFaulted) { Console.WriteLine($"Error while Exporting Entities: {completedResponse.Exception}"); throw completedResponse.Exception; } Console.WriteLine($"Entities exported successfully."); ExportEntitiesResponse result = completedResponse.Result; return(result.OutputUrl); }