更新现有作业的状态(异步)
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content demonstrates how to asynchronously update the state of an existing Dataflow job using code examples in C#, Java, Node.js, and Python.\u003c/p\u003e\n"],["\u003cp\u003eThe examples provided in C#, Java, Node.js, and Python showcase the \u003ccode\u003eUpdateJobAsync\u003c/code\u003e method of the \u003ccode\u003eJobsV1Beta3Client\u003c/code\u003e to perform asynchronous job updates.\u003c/p\u003e\n"],["\u003cp\u003eEach code example includes a snippet demonstrating the structure and basic implementation of the \u003ccode\u003eUpdateJobRequest\u003c/code\u003e, although specific details like project ID, job ID, and location may require modification.\u003c/p\u003e\n"],["\u003cp\u003eThe process for setting up authentication for Dataflow using Application Default Credentials is the same for all the languages, and a link is provided for further setup instructions.\u003c/p\u003e\n"],["\u003cp\u003eThe examples provided are templates that may require modifications to properly work, and to run, correct/in-range values for request initialization may be needed.\u003c/p\u003e\n"]]],[],null,["# Update the state of an existing job (async)\n\nDemonstrates how to update the state of an existing job asynchronously.\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 https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.html;\n using System.Threading.Tasks;\n\n public sealed partial class GeneratedJobsV1Beta3ClientSnippets\n {\n /// \u003csummary\u003eSnippet for UpdateJobAsync\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 UpdateJobRequestObjectAsync()\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.JobsV1Beta3Client.html jobsV1Beta3Client = await https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.JobsV1Beta3Client.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.JobsV1Beta3Client.html#Google_Cloud_Dataflow_V1Beta3_JobsV1Beta3Client_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.UpdateJobRequest.html request = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.UpdateJobRequest.html\n {\n ProjectId = \"\",\n JobId = \"\",\n Job = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.Job.html(),\n Location = \"\",\n UpdateMask = new https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.FieldMask.html(),\n };\n // Make the request\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.Job.html response = await jobsV1Beta3Client.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.JobsV1Beta3Client.html#Google_Cloud_Dataflow_V1Beta3_JobsV1Beta3Client_UpdateJobAsync_Google_Cloud_Dataflow_V1Beta3_UpdateJobRequest_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.Job;\n import com.google.dataflow.v1beta3.JobsV1Beta3Client;\n import com.google.dataflow.v1beta3.UpdateJobRequest;\n import com.google.protobuf.https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html;\n\n public class AsyncUpdateJob {\n\n public static void main(String[] args) throws Exception {\n asyncUpdateJob();\n }\n\n public static void asyncUpdateJob() 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 (JobsV1Beta3Client jobsV1Beta3Client = JobsV1Beta3Client.https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.SettableApiFuture.html#com_google_api_core_SettableApiFuture__V_create__()) {\n UpdateJobRequest request =\n UpdateJobRequest.newBuilder()\n .setProjectId(\"projectId-894832108\")\n .setJobId(\"jobId101296568\")\n .setJob(Job.newBuilder().build())\n .setLocation(\"location1901043637\")\n .setUpdateMask(https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html.newBuilder().build())\n .build();\n ApiFuture\u003cJob\u003e future = jobsV1Beta3Client.updateJobCallable().futureCall(request);\n // Do something.\n Job 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 job belongs to.\n */\n // const projectId = 'abc123'\n /**\n * The job ID.\n */\n // const jobId = 'abc123'\n /**\n * The updated job.\n * Only the job state is updatable; other fields will be ignored.\n */\n // const job = {}\n /**\n * The regional endpoint \n * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints) that\n * contains this job.\n */\n // const location = 'abc123'\n /**\n * The list of fields to update relative to Job. If empty, only\n * RequestedJobState will be considered for update. If the FieldMask is not\n * empty and RequestedJobState is none/empty, The fields specified in the\n * update mask will be the only ones considered for update. If both\n * RequestedJobState and update_mask are specified, an error will be returned\n * as we cannot update both state and mask.\n */\n // const updateMask = {}\n\n // Imports the Dataflow library\n const {JobsV1Beta3Client} = 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 callUpdateJob() {\n // Construct request\n const request = {\n };\n\n // Run request\n const response = await dataflowClient.updateJob(request);\n console.log(response);\n }\n\n callUpdateJob();\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_update_job():\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.jobs_v1_beta3.JobsV1Beta3AsyncClient.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.UpdateJobRequest.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.jobs_v1_beta3.JobsV1Beta3AsyncClient.html#google_cloud_dataflow_v1beta3_services_jobs_v1_beta3_JobsV1Beta3AsyncClient_update_job(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)."]]