- 2.57.0 (latest)
- 2.56.0
- 2.55.0
- 2.54.0
- 2.53.0
- 2.51.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.26.0
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.1
- 2.4.0
- 2.3.0
- 2.2.3
- 2.1.0
- 2.0.19
public class CatalogServiceClient implements BackgroundResource
Service Description: Service for managing catalog configuration.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
Catalog catalog = Catalog.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask);
}
Note: close() needs to be called on the CatalogServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CatalogServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CatalogServiceSettings catalogServiceSettings =
CatalogServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CatalogServiceSettings catalogServiceSettings =
CatalogServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final CatalogServiceClient create()
Constructs an instance of CatalogServiceClient with default settings.
Type | Description |
CatalogServiceClient |
Type | Description |
IOException |
create(CatalogServiceSettings settings)
public static final CatalogServiceClient create(CatalogServiceSettings settings)
Constructs an instance of CatalogServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | CatalogServiceSettings |
Type | Description |
CatalogServiceClient |
Type | Description |
IOException |
create(CatalogServiceStub stub)
public static final CatalogServiceClient create(CatalogServiceStub stub)
Constructs an instance of CatalogServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(CatalogServiceSettings).
Name | Description |
stub | CatalogServiceStub |
Type | Description |
CatalogServiceClient |
Constructors
CatalogServiceClient(CatalogServiceSettings settings)
protected CatalogServiceClient(CatalogServiceSettings settings)
Constructs an instance of CatalogServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | CatalogServiceSettings |
CatalogServiceClient(CatalogServiceStub stub)
protected CatalogServiceClient(CatalogServiceStub stub)
Name | Description |
stub | CatalogServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
getDefaultBranch(CatalogName catalog)
public final GetDefaultBranchResponse getDefaultBranch(CatalogName catalog)
Get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent catalog.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]");
GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog);
}
Name | Description |
catalog | CatalogName The parent catalog resource name, such as
|
Type | Description |
GetDefaultBranchResponse |
getDefaultBranch(GetDefaultBranchRequest request)
public final GetDefaultBranchResponse getDefaultBranch(GetDefaultBranchRequest request)
Get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent catalog.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
GetDefaultBranchRequest request =
GetDefaultBranchRequest.newBuilder()
.setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
.build();
GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(request);
}
Name | Description |
request | GetDefaultBranchRequest The request object containing all of the parameters for the API call. |
Type | Description |
GetDefaultBranchResponse |
getDefaultBranch(String catalog)
public final GetDefaultBranchResponse getDefaultBranch(String catalog)
Get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent catalog.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString();
GetDefaultBranchResponse response = catalogServiceClient.getDefaultBranch(catalog);
}
Name | Description |
catalog | String The parent catalog resource name, such as
|
Type | Description |
GetDefaultBranchResponse |
getDefaultBranchCallable()
public final UnaryCallable<GetDefaultBranchRequest,GetDefaultBranchResponse> getDefaultBranchCallable()
Get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent catalog.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
GetDefaultBranchRequest request =
GetDefaultBranchRequest.newBuilder()
.setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
.build();
ApiFuture<GetDefaultBranchResponse> future =
catalogServiceClient.getDefaultBranchCallable().futureCall(request);
// Do something.
GetDefaultBranchResponse response = future.get();
}
Type | Description |
UnaryCallable<GetDefaultBranchRequest,GetDefaultBranchResponse> |
getSettings()
public final CatalogServiceSettings getSettings()
Type | Description |
CatalogServiceSettings |
getStub()
public CatalogServiceStub getStub()
Type | Description |
CatalogServiceStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listCatalogs(ListCatalogsRequest request)
public final CatalogServiceClient.ListCatalogsPagedResponse listCatalogs(ListCatalogsRequest request)
Lists all the Catalogs associated with the project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
ListCatalogsRequest request =
ListCatalogsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Catalog element : catalogServiceClient.listCatalogs(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListCatalogsRequest The request object containing all of the parameters for the API call. |
Type | Description |
CatalogServiceClient.ListCatalogsPagedResponse |
listCatalogs(LocationName parent)
public final CatalogServiceClient.ListCatalogsPagedResponse listCatalogs(LocationName parent)
Lists all the Catalogs associated with the project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The account resource name with an associated location. If the caller does not have permission to list Catalogs under this location, regardless of whether or not this location exists, a PERMISSION_DENIED error is returned. |
Type | Description |
CatalogServiceClient.ListCatalogsPagedResponse |
listCatalogs(String parent)
public final CatalogServiceClient.ListCatalogsPagedResponse listCatalogs(String parent)
Lists all the Catalogs associated with the project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Catalog element : catalogServiceClient.listCatalogs(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The account resource name with an associated location. If the caller does not have permission to list Catalogs under this location, regardless of whether or not this location exists, a PERMISSION_DENIED error is returned. |
Type | Description |
CatalogServiceClient.ListCatalogsPagedResponse |
listCatalogsCallable()
public final UnaryCallable<ListCatalogsRequest,ListCatalogsResponse> listCatalogsCallable()
Lists all the Catalogs associated with the project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
ListCatalogsRequest request =
ListCatalogsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListCatalogsResponse response = catalogServiceClient.listCatalogsCallable().call(request);
for (Catalog element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListCatalogsRequest,ListCatalogsResponse> |
listCatalogsPagedCallable()
public final UnaryCallable<ListCatalogsRequest,CatalogServiceClient.ListCatalogsPagedResponse> listCatalogsPagedCallable()
Lists all the Catalogs associated with the project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
ListCatalogsRequest request =
ListCatalogsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Catalog> future =
catalogServiceClient.listCatalogsPagedCallable().futureCall(request);
// Do something.
for (Catalog element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListCatalogsRequest,ListCatalogsPagedResponse> |
setDefaultBranch(CatalogName catalog)
public final void setDefaultBranch(CatalogName catalog)
Set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default.
For example, if projects/*/locations/*/catalogs/*/branches/1
is set as
default, setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/default_branch
is equivalent to
setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/1
.
Using multiple branches can be useful when developers would like to have a staging branch to
test and verify for future usage. When it becomes ready, developers switch on the staging
branch using this API while keeping using
projects/*/locations/*/catalogs/*/branches/default_branch
as
SearchRequest.branch to route the traffic to
this staging branch.
CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one.
More specifically:
- PredictionService will only return product IDs from branch {newBranch}.
- SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set).
- UserEventService will only join events with products from branch {newBranch}.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]");
catalogServiceClient.setDefaultBranch(catalog);
}
Name | Description |
catalog | CatalogName Full resource name of the catalog, such as
|
setDefaultBranch(SetDefaultBranchRequest request)
public final void setDefaultBranch(SetDefaultBranchRequest request)
Set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default.
For example, if projects/*/locations/*/catalogs/*/branches/1
is set as
default, setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/default_branch
is equivalent to
setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/1
.
Using multiple branches can be useful when developers would like to have a staging branch to
test and verify for future usage. When it becomes ready, developers switch on the staging
branch using this API while keeping using
projects/*/locations/*/catalogs/*/branches/default_branch
as
SearchRequest.branch to route the traffic to
this staging branch.
CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one.
More specifically:
- PredictionService will only return product IDs from branch {newBranch}.
- SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set).
- UserEventService will only join events with products from branch {newBranch}.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
SetDefaultBranchRequest request =
SetDefaultBranchRequest.newBuilder()
.setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
.setBranchId(
BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString())
.setNote("note3387378")
.setForce(true)
.build();
catalogServiceClient.setDefaultBranch(request);
}
Name | Description |
request | SetDefaultBranchRequest The request object containing all of the parameters for the API call. |
setDefaultBranch(String catalog)
public final void setDefaultBranch(String catalog)
Set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default.
For example, if projects/*/locations/*/catalogs/*/branches/1
is set as
default, setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/default_branch
is equivalent to
setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/1
.
Using multiple branches can be useful when developers would like to have a staging branch to
test and verify for future usage. When it becomes ready, developers switch on the staging
branch using this API while keeping using
projects/*/locations/*/catalogs/*/branches/default_branch
as
SearchRequest.branch to route the traffic to
this staging branch.
CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one.
More specifically:
- PredictionService will only return product IDs from branch {newBranch}.
- SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set).
- UserEventService will only join events with products from branch {newBranch}.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
String catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString();
catalogServiceClient.setDefaultBranch(catalog);
}
Name | Description |
catalog | String Full resource name of the catalog, such as
|
setDefaultBranchCallable()
public final UnaryCallable<SetDefaultBranchRequest,Empty> setDefaultBranchCallable()
Set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default.
For example, if projects/*/locations/*/catalogs/*/branches/1
is set as
default, setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/default_branch
is equivalent to
setting SearchRequest.branch to
projects/*/locations/*/catalogs/*/branches/1
.
Using multiple branches can be useful when developers would like to have a staging branch to
test and verify for future usage. When it becomes ready, developers switch on the staging
branch using this API while keeping using
projects/*/locations/*/catalogs/*/branches/default_branch
as
SearchRequest.branch to route the traffic to
this staging branch.
CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one.
More specifically:
- PredictionService will only return product IDs from branch {newBranch}.
- SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set).
- UserEventService will only join events with products from branch {newBranch}.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
SetDefaultBranchRequest request =
SetDefaultBranchRequest.newBuilder()
.setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
.setBranchId(
BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString())
.setNote("note3387378")
.setForce(true)
.build();
ApiFuture<Empty> future = catalogServiceClient.setDefaultBranchCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<SetDefaultBranchRequest,Empty> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updateCatalog(Catalog catalog, FieldMask updateMask)
public final Catalog updateCatalog(Catalog catalog, FieldMask updateMask)
Updates the Catalogs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
Catalog catalog = Catalog.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask);
}
Name | Description |
catalog | Catalog Required. The Catalog to update. If the caller does not have permission to update the Catalog, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. If the Catalog to update does not exist, a NOT_FOUND error is returned. |
updateMask | FieldMask Indicates which fields in the provided Catalog to update. If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned. |
Type | Description |
Catalog |
updateCatalog(UpdateCatalogRequest request)
public final Catalog updateCatalog(UpdateCatalogRequest request)
Updates the Catalogs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
UpdateCatalogRequest request =
UpdateCatalogRequest.newBuilder()
.setCatalog(Catalog.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Catalog response = catalogServiceClient.updateCatalog(request);
}
Name | Description |
request | UpdateCatalogRequest The request object containing all of the parameters for the API call. |
Type | Description |
Catalog |
updateCatalogCallable()
public final UnaryCallable<UpdateCatalogRequest,Catalog> updateCatalogCallable()
Updates the Catalogs.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
UpdateCatalogRequest request =
UpdateCatalogRequest.newBuilder()
.setCatalog(Catalog.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Catalog> future = catalogServiceClient.updateCatalogCallable().futureCall(request);
// Do something.
Catalog response = future.get();
}
Type | Description |
UnaryCallable<UpdateCatalogRequest,Catalog> |