/// <summary>Snippet for StopExperimentAsync</summary> public async Task StopExperimentResourceNamesAsync() { // Snippet: StopExperimentAsync(ExperimentName, CallSettings) // Additional: StopExperimentAsync(ExperimentName, CancellationToken) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) ExperimentName name = ExperimentName.FromProjectLocationAgentEnvironmentExperiment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[EXPERIMENT]"); // Make the request Experiment response = await experimentsClient.StopExperimentAsync(name); // End snippet }
/// <summary>Snippet for StopExperimentAsync</summary> public async Task StopExperimentAsync() { // Snippet: StopExperimentAsync(string, CallSettings) // Additional: StopExperimentAsync(string, CancellationToken) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/environments/[ENVIRONMENT]/experiments/[EXPERIMENT]"; // Make the request Experiment response = await experimentsClient.StopExperimentAsync(name); // End snippet }
/// <summary>Snippet for UpdateExperimentAsync</summary> public async Task UpdateExperimentAsync() { // Snippet: UpdateExperimentAsync(Experiment, FieldMask, CallSettings) // Additional: UpdateExperimentAsync(Experiment, FieldMask, CancellationToken) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) Experiment experiment = new Experiment(); FieldMask updateMask = new FieldMask(); // Make the request Experiment response = await experimentsClient.UpdateExperimentAsync(experiment, updateMask); // End snippet }
/// <summary>Snippet for CreateExperimentAsync</summary> public async Task CreateExperimentResourceNamesAsync() { // Snippet: CreateExperimentAsync(EnvironmentName, Experiment, CallSettings) // Additional: CreateExperimentAsync(EnvironmentName, Experiment, CancellationToken) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) EnvironmentName parent = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"); Experiment experiment = new Experiment(); // Make the request Experiment response = await experimentsClient.CreateExperimentAsync(parent, experiment); // End snippet }
/// <summary>Snippet for CreateExperimentAsync</summary> public async Task CreateExperimentAsync() { // Snippet: CreateExperimentAsync(string, Experiment, CallSettings) // Additional: CreateExperimentAsync(string, Experiment, CancellationToken) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) string parent = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/environments/[ENVIRONMENT]"; Experiment experiment = new Experiment(); // Make the request Experiment response = await experimentsClient.CreateExperimentAsync(parent, experiment); // End snippet }
/// <summary>Snippet for ListExperiments</summary> public async Task ListExperimentsRequestObjectAsync() { // Snippet: ListExperimentsAsync(ListExperimentsRequest, CallSettings) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) ListExperimentsRequest request = new ListExperimentsRequest { ParentAsEnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"), }; // Make the request PagedAsyncEnumerable <ListExperimentsResponse, Experiment> response = experimentsClient.ListExperimentsAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Experiment item) => { // Do something with each item Console.WriteLine(item); }); // Or iterate over pages (of server-defined size), performing one RPC per page await response.AsRawResponses().ForEachAsync((ListExperimentsResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Experiment item in page) { // Do something with each item Console.WriteLine(item); } }); // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Experiment> singlePage = await response.ReadPageAsync(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Experiment item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary>Snippet for DeleteExperimentAsync</summary> public async Task DeleteExperimentRequestObjectAsync() { // Snippet: DeleteExperimentAsync(DeleteExperimentRequest, CallSettings) // Additional: DeleteExperimentAsync(DeleteExperimentRequest, CancellationToken) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) DeleteExperimentRequest request = new DeleteExperimentRequest { ExperimentName = ExperimentName.FromProjectLocationAgentEnvironmentExperiment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[EXPERIMENT]"), }; // Make the request await experimentsClient.DeleteExperimentAsync(request); // End snippet }
/// <summary>Snippet for UpdateExperimentAsync</summary> public async Task UpdateExperimentRequestObjectAsync() { // Snippet: UpdateExperimentAsync(UpdateExperimentRequest, CallSettings) // Additional: UpdateExperimentAsync(UpdateExperimentRequest, CancellationToken) // Create client ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync(); // Initialize request argument(s) UpdateExperimentRequest request = new UpdateExperimentRequest { Experiment = new Experiment(), UpdateMask = new FieldMask(), }; // Make the request Experiment response = await experimentsClient.UpdateExperimentAsync(request); // End snippet }