Menghapus cek uptime
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Mendemonstrasikan cara menghapus konfigurasi cek uptime.
Mempelajari lebih lanjut
Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:
Contoh kode
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","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-v3/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)."]]