Skip to content

Commit

Permalink
feat: add model service
Browse files Browse the repository at this point in the history
feat: support per-entity search and autocomplete
feat: support new filter syntax for recommendation
feat: expose A/B experiment info in search response
docs: keep the API doc up-to-date with recent changes

PiperOrigin-RevId: 522675951

Source-Link: googleapis/googleapis@f149e91

Source-Link: googleapis/googleapis-gen@c4538a8
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuUmV0YWlsLlYyLy5Pd2xCb3QueWFtbCIsImgiOiJjNDUzOGE4ODhkMmVjMTNjZTcxOWMxYTFhYTlkYzdkZTViMTczNzVhIn0=
  • Loading branch information
gcf-owl-bot[bot] authored and jskeet committed Apr 8, 2023
1 parent 217853b commit a54f6b9
Show file tree
Hide file tree
Showing 76 changed files with 13,861 additions and 399 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public async Task CompleteQueryRequestObjectAsync()
MaxSuggestions = 0,
Dataset = "",
VisitorId = "",
Entity = "",
};
// Make the request
CompleteQueryResponse response = await completionServiceClient.CompleteQueryAsync(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void CompleteQueryRequestObject()
MaxSuggestions = 0,
Dataset = "",
VisitorId = "",
Entity = "",
};
// Make the request
CompleteQueryResponse response = completionServiceClient.CompleteQuery(request);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2023 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 Google.Cloud.Retail.V2.Snippets
{
// [START retail_v2_generated_ModelService_CreateModel_async_flattened]
using Google.Cloud.Retail.V2;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedModelServiceClientSnippets
{
/// <summary>Snippet for CreateModelAsync</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 CreateModelAsync()
{
// Create client
ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]/catalogs/[CATALOG]";
Model model = new Model();
// Make the request
Operation<Model, CreateModelMetadata> response = await modelServiceClient.CreateModelAsync(parent, model);

// Poll until the returned long-running operation is complete
Operation<Model, CreateModelMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Model 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<Model, CreateModelMetadata> retrievedResponse = await modelServiceClient.PollOnceCreateModelAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Model retrievedResult = retrievedResponse.Result;
}
}
}
// [END retail_v2_generated_ModelService_CreateModel_async_flattened]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2023 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 Google.Cloud.Retail.V2.Snippets
{
// [START retail_v2_generated_ModelService_CreateModel_async]
using Google.Cloud.Retail.V2;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedModelServiceClientSnippets
{
/// <summary>Snippet for CreateModelAsync</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 CreateModelRequestObjectAsync()
{
// Create client
ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();
// Initialize request argument(s)
CreateModelRequest request = new CreateModelRequest
{
ParentAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
Model = new Model(),
DryRun = false,
};
// Make the request
Operation<Model, CreateModelMetadata> response = await modelServiceClient.CreateModelAsync(request);

// Poll until the returned long-running operation is complete
Operation<Model, CreateModelMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Model 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<Model, CreateModelMetadata> retrievedResponse = await modelServiceClient.PollOnceCreateModelAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Model retrievedResult = retrievedResponse.Result;
}
}
}
// [END retail_v2_generated_ModelService_CreateModel_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2023 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 Google.Cloud.Retail.V2.Snippets
{
// [START retail_v2_generated_ModelService_CreateModel_sync]
using Google.Cloud.Retail.V2;
using Google.LongRunning;

public sealed partial class GeneratedModelServiceClientSnippets
{
/// <summary>Snippet for CreateModel</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 CreateModelRequestObject()
{
// Create client
ModelServiceClient modelServiceClient = ModelServiceClient.Create();
// Initialize request argument(s)
CreateModelRequest request = new CreateModelRequest
{
ParentAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
Model = new Model(),
DryRun = false,
};
// Make the request
Operation<Model, CreateModelMetadata> response = modelServiceClient.CreateModel(request);

// Poll until the returned long-running operation is complete
Operation<Model, CreateModelMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Model 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<Model, CreateModelMetadata> retrievedResponse = modelServiceClient.PollOnceCreateModel(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Model retrievedResult = retrievedResponse.Result;
}
}
}
// [END retail_v2_generated_ModelService_CreateModel_sync]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2023 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 Google.Cloud.Retail.V2.Snippets
{
// [START retail_v2_generated_ModelService_CreateModel_async_flattened_resourceNames]
using Google.Cloud.Retail.V2;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedModelServiceClientSnippets
{
/// <summary>Snippet for CreateModelAsync</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 CreateModelResourceNamesAsync()
{
// Create client
ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();
// Initialize request argument(s)
CatalogName parent = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]");
Model model = new Model();
// Make the request
Operation<Model, CreateModelMetadata> response = await modelServiceClient.CreateModelAsync(parent, model);

// Poll until the returned long-running operation is complete
Operation<Model, CreateModelMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Model 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<Model, CreateModelMetadata> retrievedResponse = await modelServiceClient.PollOnceCreateModelAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Model retrievedResult = retrievedResponse.Result;
}
}
}
// [END retail_v2_generated_ModelService_CreateModel_async_flattened_resourceNames]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2023 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 Google.Cloud.Retail.V2.Snippets
{
// [START retail_v2_generated_ModelService_CreateModel_sync_flattened_resourceNames]
using Google.Cloud.Retail.V2;
using Google.LongRunning;

public sealed partial class GeneratedModelServiceClientSnippets
{
/// <summary>Snippet for CreateModel</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 CreateModelResourceNames()
{
// Create client
ModelServiceClient modelServiceClient = ModelServiceClient.Create();
// Initialize request argument(s)
CatalogName parent = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]");
Model model = new Model();
// Make the request
Operation<Model, CreateModelMetadata> response = modelServiceClient.CreateModel(parent, model);

// Poll until the returned long-running operation is complete
Operation<Model, CreateModelMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Model 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<Model, CreateModelMetadata> retrievedResponse = modelServiceClient.PollOnceCreateModel(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Model retrievedResult = retrievedResponse.Result;
}
}
}
// [END retail_v2_generated_ModelService_CreateModel_sync_flattened_resourceNames]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2023 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 Google.Cloud.Retail.V2.Snippets
{
// [START retail_v2_generated_ModelService_CreateModel_sync_flattened]
using Google.Cloud.Retail.V2;
using Google.LongRunning;

public sealed partial class GeneratedModelServiceClientSnippets
{
/// <summary>Snippet for CreateModel</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 CreateModel()
{
// Create client
ModelServiceClient modelServiceClient = ModelServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]/catalogs/[CATALOG]";
Model model = new Model();
// Make the request
Operation<Model, CreateModelMetadata> response = modelServiceClient.CreateModel(parent, model);

// Poll until the returned long-running operation is complete
Operation<Model, CreateModelMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Model 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<Model, CreateModelMetadata> retrievedResponse = modelServiceClient.PollOnceCreateModel(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Model retrievedResult = retrievedResponse.Result;
}
}
}
// [END retail_v2_generated_ModelService_CreateModel_sync_flattened]
}
Loading

0 comments on commit a54f6b9

Please sign in to comment.