Supprimer un test de disponibilité
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Explique comment supprimer une configuration de test de disponibilité.
En savoir plus
Pour obtenir une documentation détaillée incluant cet exemple de code, consultez les articles suivants :
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[],[],null,["Demonstrates how to delete an uptime check config.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Manage uptime checks](/monitoring/uptime-checks/manage)\n\nCode sample \n\nC#\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n public static object DeleteUptimeCheckConfig(string configName)\n {\n var client = UptimeCheckServiceClient.Create();\n client.DeleteUptimeCheckConfig(configName);\n Console.WriteLine($\"Deleted {configName}\");\n return 0;\n }\n\nGo\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n // delete is an example of deleting an uptime check. resourceName should be\n // of the form `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`.\n func delete(w io.Writer, resourceName string) error {\n \tctx := context.Background()\n \tclient, err := monitoring.NewUptimeCheckClient(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"NewUptimeCheckClient: %w\", err)\n \t}\n \tdefer client.Close()\n \treq := &monitoringpb.DeleteUptimeCheckConfigRequest{\n \t\tName: resourceName,\n \t}\n \tif err := client.DeleteUptimeCheckConfig(ctx, req); err != nil {\n \t\treturn fmt.Errorf(\"DeleteUptimeCheckConfig: %w\", err)\n \t}\n \tfmt.Fprintf(w, \"Successfully deleted %q\", resourceName)\n \treturn nil\n }\n\nJava\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n private static void deleteUptimeCheckConfig(String checkName) throws IOException {\n try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {\n client.deleteUptimeCheckConfig(checkName);\n } catch (Exception e) {\n usage(\"Exception deleting uptime check: \" + e.toString());\n throw e;\n }\n }\n\nNode.js\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n // Imports the Google Cloud client library\n const monitoring = require('https://cloud.google.com/nodejs/docs/reference/monitoring/latest/overview.html');\n\n // Creates a client\n const client = new monitoring.https://cloud.google.com/nodejs/docs/reference/monitoring/latest/overview.html();\n\n /**\n * TODO(developer): Uncomment and edit the following lines of code.\n */\n // const projectId = 'YOUR_PROJECT_ID';\n // const uptimeCheckConfigId = 'YOUR_UPTIME_CHECK_CONFIG_ID';\n\n const request = {\n // i.e. name: 'projects/my-project-id/uptimeCheckConfigs/My-Uptime-Check\n name: client.projectUptimeCheckConfigPath(projectId, uptimeCheckConfigId),\n };\n\n console.log(`Deleting ${request.name}`);\n\n // Delete an uptime check config\n await client.deleteUptimeCheckConfig(request);\n console.log(`${request.name} deleted.`);\n\nPHP\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n use Google\\Cloud\\Monitoring\\V3\\Client\\UptimeCheckServiceClient;\n use Google\\Cloud\\Monitoring\\V3\\DeleteUptimeCheckConfigRequest;\n\n /**\n * Example:\n * ```\n * delete_uptime_check($projectId, $configName);\n * ```\n *\n * @param string $projectId Your project ID\n * @param string $configName\n */\n function delete_uptime_check($projectId, $configName)\n {\n $uptimeCheckClient = new UptimeCheckServiceClient([\n 'projectId' =\u003e $projectId,\n ]);\n $deleteUptimeCheckConfigRequest = (new DeleteUptimeCheckConfigRequest())\n -\u003esetName($configName);\n\n $uptimeCheckClient-\u003edeleteUptimeCheckConfig($deleteUptimeCheckConfigRequest);\n\n printf('Deleted an uptime check: ' . $configName . PHP_EOL);\n }\n\nPython\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n # `config_name` is the `name` field of an UptimeCheckConfig.\n # See https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.uptimeCheckConfigs#UptimeCheckConfig.\n def delete_uptime_check_config(config_name: str) -\u003e None:\n \"\"\"Deletes the uptime check configuration\n\n Args:\n config_name: Uptime check configuration identity\n \"\"\"\n client = monitoring_v3.UptimeCheckServiceClient()\n client.delete_uptime_check_config(request={\"name\": config_name})\n print(\"Deleted \", config_name)\n\nRuby\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n gem \"google-cloud-monitoring\"\n require \"google/cloud/monitoring\"\n\n def delete_uptime_check_config config_name\n client = Google::Cloud::https://cloud.google.com/ruby/docs/reference/google-cloud-monitoring/latest/Google-Cloud-Monitoring.html.https://cloud.google.com/ruby/docs/reference/google-cloud-monitoring/latest/Google-Cloud-Monitoring.html\n client.delete_uptime_check_config name: config_name\n puts \"Deleted #{config_name}\"\n end\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=monitoring)."]]