Skip to content

Commit

Permalink
Updates Dataproc v1 API(#4818)
Browse files Browse the repository at this point in the history
- Adds Dataproc Jobs.SubmitJobAsOperation RPC
- Adds SparkR and Presto job types to WorkflowTemplates
- Adds new Optional Components
- Clarifies usage of some APIs 

googleapis/googleapis@9ff6fd3
commit 9ff6fd3b22f99167827e89aae7778408b5e82425
Author: Google APIs <noreply@google.com>
Date:   Mon Apr 6 09:57:56 2020 -0700

    Updates Dataproc v1 API:
    - Adds Dataproc Jobs.SubmitJobAsOperation RPC
    - Adds SparkR and Presto job types to WorkflowTemplates
    - Adds new Optional Components
    - Clarifies usage of some APIs

    PiperOrigin-RevId: 305053617
  • Loading branch information
yoshi-automation authored Apr 7, 2020
1 parent 45c8362 commit e644610
Show file tree
Hide file tree
Showing 13 changed files with 1,217 additions and 383 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace Google.Cloud.Dataproc.V1.Snippets
{
using Google.Api.Gax;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;
using System;
using System.Linq;
Expand Down Expand Up @@ -95,6 +96,140 @@ public async Task SubmitJobAsync()
// End snippet
}

/// <summary>Snippet for SubmitJobAsOperation</summary>
public void SubmitJobAsOperationRequestObject()
{
// Snippet: SubmitJobAsOperation(SubmitJobRequest, CallSettings)
// Create client
JobControllerClient jobControllerClient = JobControllerClient.Create();
// Initialize request argument(s)
SubmitJobRequest request = new SubmitJobRequest
{
ProjectId = "",
Job = new Job(),
Region = "",
RequestId = "",
};
// Make the request
Operation<Job, JobMetadata> response = jobControllerClient.SubmitJobAsOperation(request);

// Poll until the returned long-running operation is complete
Operation<Job, JobMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Job result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Job, JobMetadata> retrievedResponse = jobControllerClient.PollOnceSubmitJobAsOperation(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Job retrievedResult = retrievedResponse.Result;
}
// End snippet
}

/// <summary>Snippet for SubmitJobAsOperationAsync</summary>
public async Task SubmitJobAsOperationRequestObjectAsync()
{
// Snippet: SubmitJobAsOperationAsync(SubmitJobRequest, CallSettings)
// Additional: SubmitJobAsOperationAsync(SubmitJobRequest, CancellationToken)
// Create client
JobControllerClient jobControllerClient = await JobControllerClient.CreateAsync();
// Initialize request argument(s)
SubmitJobRequest request = new SubmitJobRequest
{
ProjectId = "",
Job = new Job(),
Region = "",
RequestId = "",
};
// Make the request
Operation<Job, JobMetadata> response = await jobControllerClient.SubmitJobAsOperationAsync(request);

// Poll until the returned long-running operation is complete
Operation<Job, JobMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Job result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Job, JobMetadata> retrievedResponse = await jobControllerClient.PollOnceSubmitJobAsOperationAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Job retrievedResult = retrievedResponse.Result;
}
// End snippet
}

/// <summary>Snippet for SubmitJobAsOperation</summary>
public void SubmitJobAsOperation()
{
// Snippet: SubmitJobAsOperation(string, string, Job, CallSettings)
// Create client
JobControllerClient jobControllerClient = JobControllerClient.Create();
// Initialize request argument(s)
string projectId = "";
string region = "";
Job job = new Job();
// Make the request
Operation<Job, JobMetadata> response = jobControllerClient.SubmitJobAsOperation(projectId, region, job);

// Poll until the returned long-running operation is complete
Operation<Job, JobMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Job result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Job, JobMetadata> retrievedResponse = jobControllerClient.PollOnceSubmitJobAsOperation(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Job retrievedResult = retrievedResponse.Result;
}
// End snippet
}

/// <summary>Snippet for SubmitJobAsOperationAsync</summary>
public async Task SubmitJobAsOperationAsync()
{
// Snippet: SubmitJobAsOperationAsync(string, string, Job, CallSettings)
// Additional: SubmitJobAsOperationAsync(string, string, Job, CancellationToken)
// Create client
JobControllerClient jobControllerClient = await JobControllerClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
string region = "";
Job job = new Job();
// Make the request
Operation<Job, JobMetadata> response = await jobControllerClient.SubmitJobAsOperationAsync(projectId, region, job);

// Poll until the returned long-running operation is complete
Operation<Job, JobMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Job result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Job, JobMetadata> retrievedResponse = await jobControllerClient.PollOnceSubmitJobAsOperationAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Job retrievedResult = retrievedResponse.Result;
}
// End snippet
}

/// <summary>Snippet for GetJob</summary>
public void GetJobRequestObject()
{
Expand Down
Loading

0 comments on commit e644610

Please sign in to comment.