Delete a snapshot (async)
Stay organized with collections
Save and categorize content based on your preferences.
Demonstrates how to delete a snapshot.
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content provides code examples in C#, Java, Node.js, and Python that demonstrate how to delete a snapshot using the Dataflow API.\u003c/p\u003e\n"],["\u003cp\u003eThe code examples require setting up Application Default Credentials for authentication with Dataflow, as detailed in the provided link.\u003c/p\u003e\n"],["\u003cp\u003eEach code sample includes instructions and placeholders that will likely require modifications to work properly, such as providing the correct project ID, snapshot ID, and location.\u003c/p\u003e\n"],["\u003cp\u003eThe provided link \u003ca href=\"/docs/samples?product=dataflow\"\u003eGoogle Cloud sample browser\u003c/a\u003e can be used to search for code samples related to other google cloud products.\u003c/p\u003e\n"]]],[],null,["# Delete a snapshot (async)\n\nDemonstrates how to delete a snapshot.\n\nCode sample\n-----------\n\n### C#\n\n\nTo authenticate to Dataflow, 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 using https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.html;\n using System.Threading.Tasks;\n\n public sealed partial class GeneratedSnapshotsV1Beta3ClientSnippets\n {\n /// \u003csummary\u003eSnippet for DeleteSnapshotAsync\u003c/summary\u003e\n /// \u003cremarks\u003e\n /// This snippet has been automatically generated and should be regarded as a code template only.\n /// It will require modifications to work:\n /// - It may require correct/in-range values for request initialization.\n /// - It may require specifying regional endpoints when creating the service client as shown in\n /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.\n /// \u003c/remarks\u003e\n public async Task DeleteSnapshotRequestObjectAsync()\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.SnapshotsV1Beta3Client.html snapshotsV1Beta3Client = await https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.SnapshotsV1Beta3Client.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.SnapshotsV1Beta3Client.html#Google_Cloud_Dataflow_V1Beta3_SnapshotsV1Beta3Client_CreateAsync_System_Threading_CancellationToken_();\n // Initialize request argument(s)\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.DeleteSnapshotRequest.html request = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.DeleteSnapshotRequest.html\n {\n ProjectId = \"\",\n SnapshotId = \"\",\n Location = \"\",\n };\n // Make the request\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.DeleteSnapshotResponse.html response = await snapshotsV1Beta3Client.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.SnapshotsV1Beta3Client.html#Google_Cloud_Dataflow_V1Beta3_SnapshotsV1Beta3Client_DeleteSnapshotAsync_Google_Cloud_Dataflow_V1Beta3_DeleteSnapshotRequest_Google_Api_Gax_Grpc_CallSettings_(request);\n }\n }\n\n### Java\n\n\nTo authenticate to Dataflow, 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 import com.google.api.core.https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFuture.html;\n import com.google.dataflow.v1beta3.DeleteSnapshotRequest;\n import com.google.dataflow.v1beta3.DeleteSnapshotResponse;\n import com.google.dataflow.v1beta3.SnapshotsV1Beta3Client;\n\n public class AsyncDeleteSnapshot {\n\n public static void main(String[] args) throws Exception {\n asyncDeleteSnapshot();\n }\n\n public static void asyncDeleteSnapshot() throws Exception {\n // This snippet has been automatically generated and should be regarded as a code template only.\n // It will require modifications to work:\n // - It may require correct/in-range values for request initialization.\n // - It may require specifying regional endpoints when creating the service client as shown in\n // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library\n try (SnapshotsV1Beta3Client snapshotsV1Beta3Client = SnapshotsV1Beta3Client.https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.SettableApiFuture.html#com_google_api_core_SettableApiFuture__V_create__()) {\n DeleteSnapshotRequest request =\n DeleteSnapshotRequest.newBuilder()\n .setProjectId(\"projectId-894832108\")\n .setSnapshotId(\"snapshotId-1113817601\")\n .setLocation(\"location1901043637\")\n .build();\n ApiFuture\u003cDeleteSnapshotResponse\u003e future =\n snapshotsV1Beta3Client.deleteSnapshotCallable().futureCall(request);\n // Do something.\n DeleteSnapshotResponse response = future.get();\n }\n }\n }\n\n### Node.js\n\n\nTo authenticate to Dataflow, 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 * This snippet has been automatically generated and should be regarded as a code template only.\n * It will require modifications to work.\n * It may require correct/in-range values for request initialization.\n * TODO(developer): Uncomment these variables before running the sample.\n */\n /**\n * The ID of the Cloud Platform project that the snapshot belongs to.\n */\n // const projectId = 'abc123'\n /**\n * The ID of the snapshot.\n */\n // const snapshotId = 'abc123'\n /**\n * The location that contains this snapshot.\n */\n // const location = 'abc123'\n\n // Imports the Dataflow library\n const {SnapshotsV1Beta3Client} = require('https://cloud.google.com/nodejs/docs/reference/dataflow/latest/overview.html').v1beta3;\n\n // Instantiates a client\n const dataflowClient = new https://cloud.google.com/nodejs/docs/reference/dataflow/latest/overview.html();\n\n async function callDeleteSnapshot() {\n // Construct request\n const request = {\n };\n\n // Run request\n const response = await dataflowClient.deleteSnapshot(request);\n console.log(response);\n }\n\n callDeleteSnapshot();\n\n### Python\n\n\nTo authenticate to Dataflow, 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 # This snippet has been automatically generated and should be regarded as a\n # code template only.\n # It will require modifications to work:\n # - It may require correct/in-range values for request initialization.\n # - It may require specifying regional endpoints when creating the service\n # client as shown in:\n # https://googleapis.dev/python/google-api-core/latest/client_options.html\n from google.cloud import https://cloud.google.com/python/docs/reference/dataflow/latest/\n\n\n async def sample_delete_snapshot():\n # Create a client\n client = https://cloud.google.com/python/docs/reference/dataflow/latest/.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.snapshots_v1_beta3.SnapshotsV1Beta3AsyncClient.html()\n\n # Initialize request argument(s)\n request = https://cloud.google.com/python/docs/reference/dataflow/latest/.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.types.DeleteSnapshotRequest.html(\n )\n\n # Make the request\n response = await client.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.snapshots_v1_beta3.SnapshotsV1Beta3AsyncClient.html#google_cloud_dataflow_v1beta3_services_snapshots_v1_beta3_SnapshotsV1Beta3AsyncClient_delete_snapshot(request=request)\n\n # Handle the response\n print(response)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=dataflow)."]]