Supprimer un profil d'application AppProfile

Supprimer un profil d'application AppProfile.

Exemple de code

C++

Pour savoir comment installer et utiliser la bibliothèque cliente pour Bigtable, consultez la page Bibliothèques clientes Bigtable.

Pour vous authentifier auprès de Bigtable, configurez les Identifiants par défaut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de développement local.

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 const& profile_id, bool ignore_warnings) {
  std::string profile_name =
      cbt::AppProfileName(project_id, instance_id, profile_id);

  google::bigtable::admin::v2::DeleteAppProfileRequest req;
  req.set_name(profile_name);
  req.set_ignore_warnings(ignore_warnings);

  Status status = instance_admin.DeleteAppProfile(std::move(req));
  if (!status.ok()) throw std::runtime_error(status.message());
  std::cout << "Application Profile deleted\n";
}

PHP

Pour savoir comment installer et utiliser la bibliothèque cliente pour Bigtable, consultez la page Bibliothèques clientes Bigtable.

Pour vous authentifier auprès de Bigtable, configurez les Identifiants par défaut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de développement local.

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

/**
 * Delete an App Profile from a Bigtable instance.
 *
 * @param string $projectId The Google Cloud project ID
 * @param string $instanceId The ID of the Bigtable instance
 * @param string $appProfileId The ID of the App Profile to be deleted
 */
function delete_app_profile(
    string $projectId,
    string $instanceId,
    string $appProfileId
): void {
    $instanceAdminClient = new BigtableInstanceAdminClient();
    $appProfileName = $instanceAdminClient->appProfileName($projectId, $instanceId, $appProfileId);
    $ignoreWarnings = true;

    printf('Deleting the App Profile: %s' . PHP_EOL, $appProfileId);

    try {
        // If $ignoreWarnings is set to false, Bigtable will warn you that all future requests using the AppProfile will fail
        $deleteAppProfileRequest = (new DeleteAppProfileRequest())
            ->setName($appProfileName)
            ->setIgnoreWarnings($ignoreWarnings);
        $instanceAdminClient->deleteAppProfile($deleteAppProfileRequest);
        printf('App Profile %s deleted.' . PHP_EOL, $appProfileId);
    } catch (ApiException $e) {
        if ($e->getStatus() === 'NOT_FOUND') {
            printf('App Profile %s does not exist.' . PHP_EOL, $appProfileId);
            return;
        }
        throw $e;
    }
}

Étapes suivantes

Pour rechercher et filtrer des exemples de code pour d'autres produits Google Cloud, consultez l'exemple de navigateur Google Cloud.