Instanz löschen

Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.

Instanz aus dem aktuellen Projekt anhand einer Instanz-ID löschen

Codebeispiel

C++

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

namespace cbt = ::google::cloud::bigtable;
namespace cbta = ::google::cloud::bigtable_admin;
using ::google::cloud::Status;
[](cbta::BigtableInstanceAdminClient instance_admin,
   std::string const& project_id, std::string const& instance_id) {
  std::string instance_name = cbt::InstanceName(project_id, instance_id);
  Status status = instance_admin.DeleteInstance(instance_name);
  if (!status.ok()) throw std::runtime_error(status.message());
  std::cout << "Successfully deleted the instance " << instance_id << "\n";
}

C#

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

// Deletes an instance from the project.
// Initialize request argument(s).
DeleteInstanceRequest request = new DeleteInstanceRequest
{
    InstanceName = new InstanceName(projectId, instanceId)
};
try
{
    // Make request.
    Console.WriteLine("Waiting for operation to complete...");
    bigtableInstanceAdminClient.DeleteInstance(request);
}
catch (Exception ex)
{
    Console.WriteLine($"Exception while deleting {instanceId} instance");
    Console.WriteLine(ex.Message);
}

Java

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

try {
  adminClient.deleteInstance(instanceId);
  System.out.println("Instance deleted: " + instanceId);
} catch (NotFoundException e) {
  System.err.println("Failed to delete non-existent instance: " + e.getMessage());
}

Node.js

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

console.log('Deleting Instance');
await instance.delete();
console.log(`Instance deleted: ${instance.id}`);

PHP

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

use Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient;
use Google\ApiCore\ApiException;

/**
 * Delete a bigtable instance
 *
 * @param string $projectId The Google Cloud project ID
 * @param string $instanceId The ID of the Bigtable instance to be deleted
 */
function delete_instance(
    string $projectId,
    string $instanceId
): void {
    $instanceAdminClient = new BigtableInstanceAdminClient();
    $instanceName = $instanceAdminClient->instanceName($projectId, $instanceId);

    printf('Deleting Instance' . PHP_EOL);
    try {
        $instanceAdminClient->deleteInstance($instanceName);
        printf('Deleted Instance: %s.' . PHP_EOL, $instanceId);
    } catch (ApiException $e) {
        if ($e->getStatus() === 'NOT_FOUND') {
            printf('Instance %s does not exists.' . PHP_EOL, $instanceId);
        } else {
            throw $e;
        }
    }
}

Python

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

print("\nDeleting instance")
if not instance.exists():
    print("Instance {} does not exist.".format(instance_id))
else:
    instance.delete()
    print("Deleted instance: {}".format(instance_id))

Ruby

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

instance.delete

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.