Skip to content

Commit

Permalink
feat: support multiple parent patterns for controls
Browse files Browse the repository at this point in the history
docs: mention multiple parent patterns for controls
PiperOrigin-RevId: 638017343

Source-Link: googleapis/googleapis@dd6a42d

Source-Link: googleapis/googleapis-gen@553fe9e
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuRGlzY292ZXJ5RW5naW5lLlYxLy5Pd2xCb3QueWFtbCIsImgiOiI1NTNmZTllNzRmYTYxYzQ3NWNkNjI1NDRiMjgzZTcwNzk1ZTg3NmNiIn0=
  • Loading branch information
gcf-owl-bot[bot] authored and amanda-tarafa committed May 29, 2024
1 parent 50fe0e3 commit c8f3726
Show file tree
Hide file tree
Showing 21 changed files with 940 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task CreateControlAsync()
// Create client
ControlServiceClient controlServiceClient = await ControlServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]/dataStores/[DATA_STORE]";
string parent = "projects/[PROJECT]/locations/[LOCATION]/collections/[COLLECTION]/engines/[ENGINE]";
Control control = new Control();
string controlId = "";
// Make the request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task CreateControlRequestObjectAsync()
// Initialize request argument(s)
CreateControlRequest request = new CreateControlRequest
{
ParentAsDataStoreName = DataStoreName.FromProjectLocationDataStore("[PROJECT]", "[LOCATION]", "[DATA_STORE]"),
ParentAsEngineName = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]"),
Control = new Control(),
ControlId = "",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void CreateControlRequestObject()
// Initialize request argument(s)
CreateControlRequest request = new CreateControlRequest
{
ParentAsDataStoreName = DataStoreName.FromProjectLocationDataStore("[PROJECT]", "[LOCATION]", "[DATA_STORE]"),
ParentAsEngineName = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]"),
Control = new Control(),
ControlId = "",
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START discoveryengine_v1_generated_ControlService_CreateControl_async_flattened_resourceNames1]
using Google.Cloud.DiscoveryEngine.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedControlServiceClientSnippets
{
/// <summary>Snippet for CreateControlAsync</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task CreateControlResourceNames1Async()
{
// Create client
ControlServiceClient controlServiceClient = await ControlServiceClient.CreateAsync();
// Initialize request argument(s)
EngineName parent = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]");
Control control = new Control();
string controlId = "";
// Make the request
Control response = await controlServiceClient.CreateControlAsync(parent, control, controlId);
}
}
// [END discoveryengine_v1_generated_ControlService_CreateControl_async_flattened_resourceNames1]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START discoveryengine_v1_generated_ControlService_CreateControl_sync_flattened_resourceNames1]
using Google.Cloud.DiscoveryEngine.V1;

public sealed partial class GeneratedControlServiceClientSnippets
{
/// <summary>Snippet for CreateControl</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void CreateControlResourceNames1()
{
// Create client
ControlServiceClient controlServiceClient = ControlServiceClient.Create();
// Initialize request argument(s)
EngineName parent = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]");
Control control = new Control();
string controlId = "";
// Make the request
Control response = controlServiceClient.CreateControl(parent, control, controlId);
}
}
// [END discoveryengine_v1_generated_ControlService_CreateControl_sync_flattened_resourceNames1]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace GoogleCSharpSnippets
{
// [START discoveryengine_v1_generated_ControlService_CreateControl_async_flattened_resourceNames]
// [START discoveryengine_v1_generated_ControlService_CreateControl_async_flattened_resourceNames2]
using Google.Cloud.DiscoveryEngine.V1;
using System.Threading.Tasks;

Expand All @@ -30,7 +30,7 @@ public sealed partial class GeneratedControlServiceClientSnippets
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task CreateControlResourceNamesAsync()
public async Task CreateControlResourceNames2Async()
{
// Create client
ControlServiceClient controlServiceClient = await ControlServiceClient.CreateAsync();
Expand All @@ -42,5 +42,5 @@ public async Task CreateControlResourceNamesAsync()
Control response = await controlServiceClient.CreateControlAsync(parent, control, controlId);
}
}
// [END discoveryengine_v1_generated_ControlService_CreateControl_async_flattened_resourceNames]
// [END discoveryengine_v1_generated_ControlService_CreateControl_async_flattened_resourceNames2]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace GoogleCSharpSnippets
{
// [START discoveryengine_v1_generated_ControlService_CreateControl_sync_flattened_resourceNames]
// [START discoveryengine_v1_generated_ControlService_CreateControl_sync_flattened_resourceNames2]
using Google.Cloud.DiscoveryEngine.V1;

public sealed partial class GeneratedControlServiceClientSnippets
Expand All @@ -29,7 +29,7 @@ public sealed partial class GeneratedControlServiceClientSnippets
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void CreateControlResourceNames()
public void CreateControlResourceNames2()
{
// Create client
ControlServiceClient controlServiceClient = ControlServiceClient.Create();
Expand All @@ -41,5 +41,5 @@ public void CreateControlResourceNames()
Control response = controlServiceClient.CreateControl(parent, control, controlId);
}
}
// [END discoveryengine_v1_generated_ControlService_CreateControl_sync_flattened_resourceNames]
// [END discoveryengine_v1_generated_ControlService_CreateControl_sync_flattened_resourceNames2]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void CreateControl()
// Create client
ControlServiceClient controlServiceClient = ControlServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]/dataStores/[DATA_STORE]";
string parent = "projects/[PROJECT]/locations/[LOCATION]/collections/[COLLECTION]/engines/[ENGINE]";
Control control = new Control();
string controlId = "";
// Make the request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task ListControlsAsync()
// Create client
ControlServiceClient controlServiceClient = await ControlServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]/dataStores/[DATA_STORE]";
string parent = "projects/[PROJECT]/locations/[LOCATION]/collections/[COLLECTION]/engines/[ENGINE]";
// Make the request
PagedAsyncEnumerable<ListControlsResponse, Control> response = controlServiceClient.ListControlsAsync(parent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task ListControlsRequestObjectAsync()
// Initialize request argument(s)
ListControlsRequest request = new ListControlsRequest
{
ParentAsDataStoreName = DataStoreName.FromProjectLocationDataStore("[PROJECT]", "[LOCATION]", "[DATA_STORE]"),
ParentAsEngineName = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]"),
Filter = "",
};
// Make the request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void ListControlsRequestObject()
// Initialize request argument(s)
ListControlsRequest request = new ListControlsRequest
{
ParentAsDataStoreName = DataStoreName.FromProjectLocationDataStore("[PROJECT]", "[LOCATION]", "[DATA_STORE]"),
ParentAsEngineName = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]"),
Filter = "",
};
// Make the request
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START discoveryengine_v1_generated_ControlService_ListControls_async_flattened_resourceNames1]
using Google.Api.Gax;
using Google.Cloud.DiscoveryEngine.V1;
using System;
using System.Linq;
using System.Threading.Tasks;

public sealed partial class GeneratedControlServiceClientSnippets
{
/// <summary>Snippet for ListControlsAsync</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task ListControlsResourceNames1Async()
{
// Create client
ControlServiceClient controlServiceClient = await ControlServiceClient.CreateAsync();
// Initialize request argument(s)
EngineName parent = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]");
// Make the request
PagedAsyncEnumerable<ListControlsResponse, Control> response = controlServiceClient.ListControlsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Control 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((ListControlsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Control 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<Control> 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 (Control 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 discoveryengine_v1_generated_ControlService_ListControls_async_flattened_resourceNames1]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START discoveryengine_v1_generated_ControlService_ListControls_sync_flattened_resourceNames1]
using Google.Api.Gax;
using Google.Cloud.DiscoveryEngine.V1;
using System;

public sealed partial class GeneratedControlServiceClientSnippets
{
/// <summary>Snippet for ListControls</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void ListControlsResourceNames1()
{
// Create client
ControlServiceClient controlServiceClient = ControlServiceClient.Create();
// Initialize request argument(s)
EngineName parent = EngineName.FromProjectLocationCollectionEngine("[PROJECT]", "[LOCATION]", "[COLLECTION]", "[ENGINE]");
// Make the request
PagedEnumerable<ListControlsResponse, Control> response = controlServiceClient.ListControls(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Control item in response)
{
// Do something with each item
Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListControlsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Control 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<Control> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Control 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 discoveryengine_v1_generated_ControlService_ListControls_sync_flattened_resourceNames1]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace GoogleCSharpSnippets
{
// [START discoveryengine_v1_generated_ControlService_ListControls_async_flattened_resourceNames]
// [START discoveryengine_v1_generated_ControlService_ListControls_async_flattened_resourceNames2]
using Google.Api.Gax;
using Google.Cloud.DiscoveryEngine.V1;
using System;
Expand All @@ -33,7 +33,7 @@ public sealed partial class GeneratedControlServiceClientSnippets
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task ListControlsResourceNamesAsync()
public async Task ListControlsResourceNames2Async()
{
// Create client
ControlServiceClient controlServiceClient = await ControlServiceClient.CreateAsync();
Expand Down Expand Up @@ -75,5 +75,5 @@ public async Task ListControlsResourceNamesAsync()
string nextPageToken = singlePage.NextPageToken;
}
}
// [END discoveryengine_v1_generated_ControlService_ListControls_async_flattened_resourceNames]
// [END discoveryengine_v1_generated_ControlService_ListControls_async_flattened_resourceNames2]
}
Loading

0 comments on commit c8f3726

Please sign in to comment.