Skip to content

Commit

Permalink
feat: Generate idiomatic LROs for Google.Cloud.Compute.V1
Browse files Browse the repository at this point in the history
  • Loading branch information
jskeet committed Oct 14, 2021
1 parent e089149 commit 77a75b3
Show file tree
Hide file tree
Showing 201 changed files with 45,731 additions and 60,502 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Google.Cloud.Compute.V1.Snippets
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using lro = Google.LongRunning;

/// <summary>Generated snippets.</summary>
public sealed class GeneratedAddressesClientSnippets
Expand Down Expand Up @@ -234,7 +235,23 @@ public void DeleteRequestObject()
Address = "",
};
// Make the request
Operation response = addressesClient.Delete(request);
lro::Operation<Operation, Operation> response = addressesClient.Delete(request);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = addressesClient.PollOnceDelete(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand All @@ -254,7 +271,23 @@ public async Task DeleteRequestObjectAsync()
Address = "",
};
// Make the request
Operation response = await addressesClient.DeleteAsync(request);
lro::Operation<Operation, Operation> response = await addressesClient.DeleteAsync(request);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = await addressesClient.PollOnceDeleteAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand All @@ -269,7 +302,23 @@ public void Delete()
string region = "";
string address = "";
// Make the request
Operation response = addressesClient.Delete(project, region, address);
lro::Operation<Operation, Operation> response = addressesClient.Delete(project, region, address);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = addressesClient.PollOnceDelete(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand All @@ -285,7 +334,23 @@ public async Task DeleteAsync()
string region = "";
string address = "";
// Make the request
Operation response = await addressesClient.DeleteAsync(project, region, address);
lro::Operation<Operation, Operation> response = await addressesClient.DeleteAsync(project, region, address);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = await addressesClient.PollOnceDeleteAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand Down Expand Up @@ -372,7 +437,23 @@ public void InsertRequestObject()
AddressResource = new Address(),
};
// Make the request
Operation response = addressesClient.Insert(request);
lro::Operation<Operation, Operation> response = addressesClient.Insert(request);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = addressesClient.PollOnceInsert(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand All @@ -392,7 +473,23 @@ public async Task InsertRequestObjectAsync()
AddressResource = new Address(),
};
// Make the request
Operation response = await addressesClient.InsertAsync(request);
lro::Operation<Operation, Operation> response = await addressesClient.InsertAsync(request);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = await addressesClient.PollOnceInsertAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand All @@ -407,7 +504,23 @@ public void Insert()
string region = "";
Address addressResource = new Address();
// Make the request
Operation response = addressesClient.Insert(project, region, addressResource);
lro::Operation<Operation, Operation> response = addressesClient.Insert(project, region, addressResource);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = addressesClient.PollOnceInsert(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand All @@ -423,7 +536,23 @@ public async Task InsertAsync()
string region = "";
Address addressResource = new Address();
// Make the request
Operation response = await addressesClient.InsertAsync(project, region, addressResource);
lro::Operation<Operation, Operation> response = await addressesClient.InsertAsync(project, region, addressResource);

// Poll until the returned long-running operation is complete
lro::Operation<Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Operation 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
lro::Operation<Operation, Operation> retrievedResponse = await addressesClient.PollOnceInsertAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Operation retrievedResult = retrievedResponse.Result;
}
// End snippet
}

Expand Down
Loading

0 comments on commit 77a75b3

Please sign in to comment.