From 11c00f7f398958feebadccc0b298996da229aa6a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 24 Jun 2022 17:46:18 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#471) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- java-retail/README.md | 4 +- java-retail/google-cloud-retail/pom.xml | 16 + .../cloud/retail/v2/CatalogServiceClient.java | 14 + .../retail/v2/CatalogServiceSettings.java | 23 +- .../retail/v2/CompletionServiceClient.java | 38 +- .../retail/v2/CompletionServiceSettings.java | 23 +- .../retail/v2/PredictionServiceClient.java | 15 + .../retail/v2/PredictionServiceSettings.java | 23 +- .../cloud/retail/v2/ProductServiceClient.java | 37 +- .../retail/v2/ProductServiceSettings.java | 23 +- .../cloud/retail/v2/SearchServiceClient.java | 14 + .../retail/v2/SearchServiceSettings.java | 23 +- .../retail/v2/UserEventServiceClient.java | 38 +- .../retail/v2/UserEventServiceSettings.java | 23 +- .../v2/stub/CatalogServiceStubSettings.java | 53 +- .../retail/v2/stub/CompletionServiceStub.java | 6 +- .../stub/CompletionServiceStubSettings.java | 53 +- ...HttpJsonCatalogServiceCallableFactory.java | 105 ++ .../v2/stub/HttpJsonCatalogServiceStub.java | 365 +++++ ...pJsonCompletionServiceCallableFactory.java | 105 ++ .../stub/HttpJsonCompletionServiceStub.java | 291 ++++ ...pJsonPredictionServiceCallableFactory.java | 105 ++ .../stub/HttpJsonPredictionServiceStub.java | 194 +++ ...HttpJsonProductServiceCallableFactory.java | 105 ++ .../v2/stub/HttpJsonProductServiceStub.java | 895 +++++++++++ .../HttpJsonSearchServiceCallableFactory.java | 105 ++ .../v2/stub/HttpJsonSearchServiceStub.java | 204 +++ ...tpJsonUserEventServiceCallableFactory.java | 105 ++ .../v2/stub/HttpJsonUserEventServiceStub.java | 481 ++++++ .../stub/PredictionServiceStubSettings.java | 53 +- .../retail/v2/stub/ProductServiceStub.java | 6 +- .../v2/stub/ProductServiceStubSettings.java | 53 +- .../v2/stub/SearchServiceStubSettings.java | 53 +- .../retail/v2/stub/UserEventServiceStub.java | 6 +- .../v2/stub/UserEventServiceStubSettings.java | 53 +- .../retail/v2alpha/CatalogServiceClient.java | 14 + .../v2alpha/CatalogServiceSettings.java | 23 +- .../v2alpha/CompletionServiceClient.java | 38 +- .../v2alpha/CompletionServiceSettings.java | 23 +- .../retail/v2alpha/ControlServiceClient.java | 14 + .../v2alpha/ControlServiceSettings.java | 23 +- .../v2alpha/PredictionServiceClient.java | 15 + .../v2alpha/PredictionServiceSettings.java | 23 +- .../retail/v2alpha/ProductServiceClient.java | 37 +- .../v2alpha/ProductServiceSettings.java | 23 +- .../retail/v2alpha/SearchServiceClient.java | 14 + .../retail/v2alpha/SearchServiceSettings.java | 23 +- .../v2alpha/ServingConfigServiceClient.java | 15 + .../v2alpha/ServingConfigServiceSettings.java | 23 +- .../v2alpha/UserEventServiceClient.java | 38 +- .../v2alpha/UserEventServiceSettings.java | 23 +- .../stub/CatalogServiceStubSettings.java | 53 +- .../v2alpha/stub/CompletionServiceStub.java | 6 +- .../stub/CompletionServiceStubSettings.java | 53 +- .../stub/ControlServiceStubSettings.java | 53 +- ...HttpJsonCatalogServiceCallableFactory.java | 105 ++ .../stub/HttpJsonCatalogServiceStub.java | 772 ++++++++++ ...pJsonCompletionServiceCallableFactory.java | 105 ++ .../stub/HttpJsonCompletionServiceStub.java | 292 ++++ ...HttpJsonControlServiceCallableFactory.java | 105 ++ .../stub/HttpJsonControlServiceStub.java | 410 +++++ ...pJsonPredictionServiceCallableFactory.java | 105 ++ .../stub/HttpJsonPredictionServiceStub.java | 194 +++ ...HttpJsonProductServiceCallableFactory.java | 105 ++ .../stub/HttpJsonProductServiceStub.java | 973 ++++++++++++ .../HttpJsonSearchServiceCallableFactory.java | 105 ++ .../stub/HttpJsonSearchServiceStub.java | 204 +++ ...onServingConfigServiceCallableFactory.java | 105 ++ .../HttpJsonServingConfigServiceStub.java | 544 +++++++ ...tpJsonUserEventServiceCallableFactory.java | 105 ++ .../stub/HttpJsonUserEventServiceStub.java | 481 ++++++ .../stub/PredictionServiceStubSettings.java | 53 +- .../v2alpha/stub/ProductServiceStub.java | 6 +- .../stub/ProductServiceStubSettings.java | 53 +- .../stub/SearchServiceStubSettings.java | 53 +- .../ServingConfigServiceStubSettings.java | 53 +- .../v2alpha/stub/UserEventServiceStub.java | 6 +- .../stub/UserEventServiceStubSettings.java | 53 +- .../retail/v2beta/CatalogServiceClient.java | 14 + .../retail/v2beta/CatalogServiceSettings.java | 23 +- .../v2beta/CompletionServiceClient.java | 38 +- .../v2beta/CompletionServiceSettings.java | 23 +- .../retail/v2beta/ControlServiceClient.java | 14 + .../retail/v2beta/ControlServiceSettings.java | 23 +- .../v2beta/PredictionServiceClient.java | 15 + .../v2beta/PredictionServiceSettings.java | 23 +- .../retail/v2beta/ProductServiceClient.java | 37 +- .../retail/v2beta/ProductServiceSettings.java | 23 +- .../retail/v2beta/SearchServiceClient.java | 14 + .../retail/v2beta/SearchServiceSettings.java | 23 +- .../v2beta/ServingConfigServiceClient.java | 15 + .../v2beta/ServingConfigServiceSettings.java | 23 +- .../retail/v2beta/UserEventServiceClient.java | 38 +- .../v2beta/UserEventServiceSettings.java | 23 +- .../stub/CatalogServiceStubSettings.java | 53 +- .../v2beta/stub/CompletionServiceStub.java | 6 +- .../stub/CompletionServiceStubSettings.java | 53 +- .../stub/ControlServiceStubSettings.java | 53 +- ...HttpJsonCatalogServiceCallableFactory.java | 105 ++ .../stub/HttpJsonCatalogServiceStub.java | 769 ++++++++++ ...pJsonCompletionServiceCallableFactory.java | 105 ++ .../stub/HttpJsonCompletionServiceStub.java | 292 ++++ ...HttpJsonControlServiceCallableFactory.java | 105 ++ .../stub/HttpJsonControlServiceStub.java | 410 +++++ ...pJsonPredictionServiceCallableFactory.java | 105 ++ .../stub/HttpJsonPredictionServiceStub.java | 194 +++ ...HttpJsonProductServiceCallableFactory.java | 105 ++ .../stub/HttpJsonProductServiceStub.java | 896 +++++++++++ .../HttpJsonSearchServiceCallableFactory.java | 105 ++ .../stub/HttpJsonSearchServiceStub.java | 204 +++ ...onServingConfigServiceCallableFactory.java | 105 ++ .../HttpJsonServingConfigServiceStub.java | 543 +++++++ ...tpJsonUserEventServiceCallableFactory.java | 105 ++ .../stub/HttpJsonUserEventServiceStub.java | 481 ++++++ .../stub/PredictionServiceStubSettings.java | 53 +- .../v2beta/stub/ProductServiceStub.java | 6 +- .../stub/ProductServiceStubSettings.java | 53 +- .../stub/SearchServiceStubSettings.java | 53 +- .../ServingConfigServiceStubSettings.java | 53 +- .../v2beta/stub/UserEventServiceStub.java | 6 +- .../stub/UserEventServiceStubSettings.java | 53 +- .../v2/CatalogServiceClientHttpJsonTest.java | 410 +++++ .../CompletionServiceClientHttpJsonTest.java | 201 +++ .../PredictionServiceClientHttpJsonTest.java | 145 ++ .../v2/ProductServiceClientHttpJsonTest.java | 1300 ++++++++++++++++ .../v2/SearchServiceClientHttpJsonTest.java | 177 +++ .../UserEventServiceClientHttpJsonTest.java | 382 +++++ .../CatalogServiceClientHttpJsonTest.java | 928 +++++++++++ .../CompletionServiceClientHttpJsonTest.java | 201 +++ .../ControlServiceClientHttpJsonTest.java | 529 +++++++ .../PredictionServiceClientHttpJsonTest.java | 145 ++ .../ProductServiceClientHttpJsonTest.java | 1361 +++++++++++++++++ .../SearchServiceClientHttpJsonTest.java | 172 +++ ...ervingConfigServiceClientHttpJsonTest.java | 888 +++++++++++ .../UserEventServiceClientHttpJsonTest.java | 382 +++++ .../CatalogServiceClientHttpJsonTest.java | 928 +++++++++++ .../CompletionServiceClientHttpJsonTest.java | 201 +++ .../ControlServiceClientHttpJsonTest.java | 522 +++++++ .../PredictionServiceClientHttpJsonTest.java | 145 ++ .../ProductServiceClientHttpJsonTest.java | 1300 ++++++++++++++++ .../SearchServiceClientHttpJsonTest.java | 172 +++ ...ervingConfigServiceClientHttpJsonTest.java | 888 +++++++++++ .../UserEventServiceClientHttpJsonTest.java | 382 +++++ .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncGetDefaultBranch.java | 47 + .../SyncGetDefaultBranch.java | 43 + .../SyncGetDefaultBranchCatalogname.java | 39 + .../SyncGetDefaultBranchString.java | 39 + .../listcatalogs/AsyncListCatalogs.java | 51 + .../listcatalogs/AsyncListCatalogsPaged.java | 58 + .../listcatalogs/SyncListCatalogs.java | 47 + .../SyncListCatalogsLocationname.java | 41 + .../listcatalogs/SyncListCatalogsString.java | 41 + .../AsyncSetDefaultBranch.java | 51 + .../SyncSetDefaultBranch.java | 48 + .../SyncSetDefaultBranchCatalogname.java | 39 + .../SyncSetDefaultBranchString.java | 39 + .../updatecatalog/AsyncUpdateCatalog.java | 47 + .../updatecatalog/SyncUpdateCatalog.java | 44 + .../SyncUpdateCatalogCatalogFieldmask.java | 40 + .../updatecatalog/SyncUpdateCatalog.java | 46 + .../completequery/AsyncCompleteQuery.java | 54 + .../completequery/SyncCompleteQuery.java | 50 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncImportCompletionData.java | 50 + .../AsyncImportCompletionDataLRO.java | 51 + .../SyncImportCompletionData.java | 47 + .../completequery/SyncCompleteQuery.java | 46 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../predict/AsyncPredict.java | 56 + .../predict/SyncPredict.java | 52 + .../predict/SyncPredict.java | 46 + .../AsyncAddFulfillmentPlaces.java | 55 + .../AsyncAddFulfillmentPlacesLRO.java | 56 + .../SyncAddFulfillmentPlaces.java | 52 + .../SyncAddFulfillmentPlacesProductname.java | 41 + .../SyncAddFulfillmentPlacesString.java | 42 + .../AsyncAddLocalInventories.java | 57 + .../AsyncAddLocalInventoriesLRO.java | 58 + .../SyncAddLocalInventories.java | 54 + .../SyncAddLocalInventoriesProductname.java | 41 + .../SyncAddLocalInventoriesString.java | 42 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createproduct/AsyncCreateProduct.java | 49 + .../createproduct/SyncCreateProduct.java | 46 + ...cCreateProductBranchnameProductString.java | 41 + .../SyncCreateProductStringProductString.java | 41 + .../deleteproduct/AsyncDeleteProduct.java | 48 + .../deleteproduct/SyncDeleteProduct.java | 45 + .../SyncDeleteProductProductname.java | 40 + .../SyncDeleteProductString.java | 41 + .../getproduct/AsyncGetProduct.java | 48 + .../getproduct/SyncGetProduct.java | 45 + .../getproduct/SyncGetProductProductname.java | 40 + .../getproduct/SyncGetProductString.java | 41 + .../importproducts/AsyncImportProducts.java | 56 + .../AsyncImportProductsLRO.java | 57 + .../importproducts/SyncImportProducts.java | 52 + .../listproducts/AsyncListProducts.java | 55 + .../listproducts/AsyncListProductsPaged.java | 62 + .../listproducts/SyncListProducts.java | 51 + .../SyncListProductsBranchname.java | 41 + .../listproducts/SyncListProductsString.java | 41 + .../AsyncRemoveFulfillmentPlaces.java | 55 + .../AsyncRemoveFulfillmentPlacesLRO.java | 56 + .../SyncRemoveFulfillmentPlaces.java | 52 + ...yncRemoveFulfillmentPlacesProductname.java | 41 + .../SyncRemoveFulfillmentPlacesString.java | 42 + .../AsyncRemoveLocalInventories.java | 54 + .../AsyncRemoveLocalInventoriesLRO.java | 55 + .../SyncRemoveLocalInventories.java | 51 + ...SyncRemoveLocalInventoriesProductname.java | 41 + .../SyncRemoveLocalInventoriesString.java | 42 + .../setinventory/AsyncSetInventory.java | 51 + .../setinventory/AsyncSetInventoryLRO.java | 53 + .../setinventory/SyncSetInventory.java | 48 + .../SyncSetInventoryProductFieldmask.java | 42 + .../updateproduct/AsyncUpdateProduct.java | 48 + .../updateproduct/SyncUpdateProduct.java | 45 + .../SyncUpdateProductProductFieldmask.java | 40 + .../createproduct/SyncCreateProduct.java | 46 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../search/AsyncSearch.java | 72 + .../search/AsyncSearchPaged.java | 78 + .../search/SyncSearch.java | 68 + .../search/SyncSearch.java | 45 + .../updatecatalog/SyncUpdateCatalog.java | 46 + .../completequery/SyncCompleteQuery.java | 47 + .../predict/SyncPredict.java | 47 + .../createproduct/SyncCreateProduct.java | 46 + .../search/SyncSearch.java | 46 + .../writeuserevent/SyncWriteUserEvent.java | 46 + .../AsyncCollectUserEvent.java | 49 + .../SyncCollectUserEvent.java | 45 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncImportUserEvents.java | 51 + .../AsyncImportUserEventsLRO.java | 52 + .../SyncImportUserEvents.java | 48 + .../purgeuserevents/AsyncPurgeUserEvents.java | 49 + .../AsyncPurgeUserEventsLRO.java | 50 + .../purgeuserevents/SyncPurgeUserEvents.java | 45 + .../AsyncRejoinUserEvents.java | 44 + .../AsyncRejoinUserEventsLRO.java | 45 + .../SyncRejoinUserEvents.java | 41 + .../writeuserevent/AsyncWriteUserEvent.java | 47 + .../writeuserevent/SyncWriteUserEvent.java | 43 + .../writeuserevent/SyncWriteUserEvent.java | 46 + .../AsyncAddCatalogAttribute.java | 50 + .../SyncAddCatalogAttribute.java | 46 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncGetAttributesConfig.java | 47 + .../SyncGetAttributesConfig.java | 43 + ...tAttributesConfigAttributesconfigname.java | 39 + .../SyncGetAttributesConfigString.java | 39 + .../AsyncGetCompletionConfig.java | 47 + .../SyncGetCompletionConfig.java | 43 + ...tCompletionConfigCompletionconfigname.java | 39 + .../SyncGetCompletionConfigString.java | 39 + .../AsyncGetDefaultBranch.java | 47 + .../SyncGetDefaultBranch.java | 43 + .../SyncGetDefaultBranchCatalogname.java | 39 + .../SyncGetDefaultBranchString.java | 39 + .../listcatalogs/AsyncListCatalogs.java | 51 + .../listcatalogs/AsyncListCatalogsPaged.java | 58 + .../listcatalogs/SyncListCatalogs.java | 47 + .../SyncListCatalogsLocationname.java | 41 + .../listcatalogs/SyncListCatalogsString.java | 41 + .../AsyncRemoveCatalogAttribute.java | 49 + .../SyncRemoveCatalogAttribute.java | 45 + .../AsyncReplaceCatalogAttribute.java | 52 + .../SyncReplaceCatalogAttribute.java | 48 + .../AsyncSetDefaultBranch.java | 51 + .../SyncSetDefaultBranch.java | 48 + .../SyncSetDefaultBranchCatalogname.java | 39 + .../SyncSetDefaultBranchString.java | 39 + .../AsyncUpdateAttributesConfig.java | 48 + .../SyncUpdateAttributesConfig.java | 44 + ...ibutesConfigAttributesconfigFieldmask.java | 41 + .../updatecatalog/AsyncUpdateCatalog.java | 47 + .../updatecatalog/SyncUpdateCatalog.java | 44 + .../SyncUpdateCatalogCatalogFieldmask.java | 40 + .../AsyncUpdateCompletionConfig.java | 48 + .../SyncUpdateCompletionConfig.java | 44 + ...letionConfigCompletionconfigFieldmask.java | 41 + .../updatecatalog/SyncUpdateCatalog.java | 46 + .../completequery/AsyncCompleteQuery.java | 54 + .../completequery/SyncCompleteQuery.java | 50 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncImportCompletionData.java | 50 + .../AsyncImportCompletionDataLRO.java | 51 + .../SyncImportCompletionData.java | 47 + .../completequery/SyncCompleteQuery.java | 46 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createcontrol/AsyncCreateControl.java | 48 + .../createcontrol/SyncCreateControl.java | 45 + ...CreateControlCatalognameControlString.java | 41 + .../SyncCreateControlStringControlString.java | 41 + .../deletecontrol/AsyncDeleteControl.java | 47 + .../deletecontrol/SyncDeleteControl.java | 44 + .../SyncDeleteControlControlname.java | 39 + .../SyncDeleteControlString.java | 39 + .../getcontrol/AsyncGetControl.java | 47 + .../getcontrol/SyncGetControl.java | 44 + .../getcontrol/SyncGetControlControlname.java | 39 + .../getcontrol/SyncGetControlString.java | 39 + .../listcontrols/AsyncListControls.java | 52 + .../listcontrols/AsyncListControlsPaged.java | 59 + .../listcontrols/SyncListControls.java | 48 + .../SyncListControlsCatalogname.java | 41 + .../listcontrols/SyncListControlsString.java | 41 + .../updatecontrol/AsyncUpdateControl.java | 47 + .../updatecontrol/SyncUpdateControl.java | 44 + .../SyncUpdateControlControlFieldmask.java | 40 + .../createcontrol/SyncCreateControl.java | 46 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../predict/AsyncPredict.java | 56 + .../predict/SyncPredict.java | 52 + .../predict/SyncPredict.java | 46 + .../AsyncAddFulfillmentPlaces.java | 55 + .../AsyncAddFulfillmentPlacesLRO.java | 56 + .../SyncAddFulfillmentPlaces.java | 52 + .../SyncAddFulfillmentPlacesProductname.java | 41 + .../SyncAddFulfillmentPlacesString.java | 42 + .../AsyncAddLocalInventories.java | 57 + .../AsyncAddLocalInventoriesLRO.java | 58 + .../SyncAddLocalInventories.java | 54 + .../SyncAddLocalInventoriesProductname.java | 41 + .../SyncAddLocalInventoriesString.java | 42 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createproduct/AsyncCreateProduct.java | 49 + .../createproduct/SyncCreateProduct.java | 46 + ...cCreateProductBranchnameProductString.java | 41 + .../SyncCreateProductStringProductString.java | 41 + .../deleteproduct/AsyncDeleteProduct.java | 48 + .../deleteproduct/SyncDeleteProduct.java | 45 + .../SyncDeleteProductProductname.java | 40 + .../SyncDeleteProductString.java | 41 + .../getproduct/AsyncGetProduct.java | 48 + .../getproduct/SyncGetProduct.java | 45 + .../getproduct/SyncGetProductProductname.java | 40 + .../getproduct/SyncGetProductString.java | 41 + .../importproducts/AsyncImportProducts.java | 56 + .../AsyncImportProductsLRO.java | 57 + .../importproducts/SyncImportProducts.java | 52 + .../listproducts/AsyncListProducts.java | 56 + .../listproducts/AsyncListProductsPaged.java | 63 + .../listproducts/SyncListProducts.java | 52 + .../SyncListProductsBranchname.java | 41 + .../listproducts/SyncListProductsString.java | 41 + .../purgeproducts/AsyncPurgeProducts.java | 50 + .../purgeproducts/AsyncPurgeProductsLRO.java | 51 + .../purgeproducts/SyncPurgeProducts.java | 46 + .../AsyncRemoveFulfillmentPlaces.java | 55 + .../AsyncRemoveFulfillmentPlacesLRO.java | 56 + .../SyncRemoveFulfillmentPlaces.java | 52 + ...yncRemoveFulfillmentPlacesProductname.java | 41 + .../SyncRemoveFulfillmentPlacesString.java | 42 + .../AsyncRemoveLocalInventories.java | 54 + .../AsyncRemoveLocalInventoriesLRO.java | 55 + .../SyncRemoveLocalInventories.java | 51 + ...SyncRemoveLocalInventoriesProductname.java | 41 + .../SyncRemoveLocalInventoriesString.java | 42 + .../setinventory/AsyncSetInventory.java | 51 + .../setinventory/AsyncSetInventoryLRO.java | 53 + .../setinventory/SyncSetInventory.java | 48 + .../SyncSetInventoryProductFieldmask.java | 42 + .../updateproduct/AsyncUpdateProduct.java | 48 + .../updateproduct/SyncUpdateProduct.java | 45 + .../SyncUpdateProductProductFieldmask.java | 40 + .../createproduct/SyncCreateProduct.java | 46 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../search/AsyncSearch.java | 69 + .../search/AsyncSearchPaged.java | 75 + .../search/SyncSearch.java | 65 + .../search/SyncSearch.java | 45 + .../addcontrol/AsyncAddControl.java | 51 + .../addcontrol/SyncAddControl.java | 47 + .../SyncAddControlServingconfigname.java | 41 + .../addcontrol/SyncAddControlString.java | 42 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateServingConfig.java | 50 + .../SyncCreateServingConfig.java | 46 + ...gConfigCatalognameServingconfigString.java | 43 + ...ervingConfigStringServingconfigString.java | 43 + .../AsyncDeleteServingConfig.java | 50 + .../SyncDeleteServingConfig.java | 46 + ...cDeleteServingConfigServingconfigname.java | 41 + .../SyncDeleteServingConfigString.java | 42 + .../AsyncGetServingConfig.java | 50 + .../SyncGetServingConfig.java | 46 + ...SyncGetServingConfigServingconfigname.java | 41 + .../SyncGetServingConfigString.java | 42 + .../AsyncListServingConfigs.java | 52 + .../AsyncListServingConfigsPaged.java | 60 + .../SyncListServingConfigs.java | 49 + .../SyncListServingConfigsCatalogname.java | 43 + .../SyncListServingConfigsString.java | 43 + .../removecontrol/AsyncRemoveControl.java | 51 + .../removecontrol/SyncRemoveControl.java | 47 + .../SyncRemoveControlServingconfigname.java | 41 + .../SyncRemoveControlString.java | 42 + .../AsyncUpdateServingConfig.java | 49 + .../SyncUpdateServingConfig.java | 45 + ...teServingConfigServingconfigFieldmask.java | 42 + .../SyncCreateServingConfig.java | 47 + .../updatecatalog/SyncUpdateCatalog.java | 46 + .../completequery/SyncCompleteQuery.java | 47 + .../createcontrol/SyncCreateControl.java | 46 + .../predict/SyncPredict.java | 47 + .../createproduct/SyncCreateProduct.java | 46 + .../search/SyncSearch.java | 46 + .../SyncCreateServingConfig.java | 47 + .../writeuserevent/SyncWriteUserEvent.java | 46 + .../AsyncCollectUserEvent.java | 49 + .../SyncCollectUserEvent.java | 45 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncImportUserEvents.java | 51 + .../AsyncImportUserEventsLRO.java | 52 + .../SyncImportUserEvents.java | 48 + .../purgeuserevents/AsyncPurgeUserEvents.java | 48 + .../AsyncPurgeUserEventsLRO.java | 49 + .../purgeuserevents/SyncPurgeUserEvents.java | 44 + .../AsyncRejoinUserEvents.java | 44 + .../AsyncRejoinUserEventsLRO.java | 45 + .../SyncRejoinUserEvents.java | 41 + .../writeuserevent/AsyncWriteUserEvent.java | 47 + .../writeuserevent/SyncWriteUserEvent.java | 43 + .../writeuserevent/SyncWriteUserEvent.java | 46 + .../AsyncAddCatalogAttribute.java | 50 + .../SyncAddCatalogAttribute.java | 46 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncGetAttributesConfig.java | 47 + .../SyncGetAttributesConfig.java | 43 + ...tAttributesConfigAttributesconfigname.java | 39 + .../SyncGetAttributesConfigString.java | 39 + .../AsyncGetCompletionConfig.java | 47 + .../SyncGetCompletionConfig.java | 43 + ...tCompletionConfigCompletionconfigname.java | 39 + .../SyncGetCompletionConfigString.java | 39 + .../AsyncGetDefaultBranch.java | 47 + .../SyncGetDefaultBranch.java | 43 + .../SyncGetDefaultBranchCatalogname.java | 39 + .../SyncGetDefaultBranchString.java | 39 + .../listcatalogs/AsyncListCatalogs.java | 51 + .../listcatalogs/AsyncListCatalogsPaged.java | 58 + .../listcatalogs/SyncListCatalogs.java | 47 + .../SyncListCatalogsLocationname.java | 41 + .../listcatalogs/SyncListCatalogsString.java | 41 + .../AsyncRemoveCatalogAttribute.java | 49 + .../SyncRemoveCatalogAttribute.java | 45 + .../AsyncReplaceCatalogAttribute.java | 52 + .../SyncReplaceCatalogAttribute.java | 48 + .../AsyncSetDefaultBranch.java | 51 + .../SyncSetDefaultBranch.java | 48 + .../SyncSetDefaultBranchCatalogname.java | 39 + .../SyncSetDefaultBranchString.java | 39 + .../AsyncUpdateAttributesConfig.java | 48 + .../SyncUpdateAttributesConfig.java | 44 + ...ibutesConfigAttributesconfigFieldmask.java | 41 + .../updatecatalog/AsyncUpdateCatalog.java | 47 + .../updatecatalog/SyncUpdateCatalog.java | 44 + .../SyncUpdateCatalogCatalogFieldmask.java | 40 + .../AsyncUpdateCompletionConfig.java | 48 + .../SyncUpdateCompletionConfig.java | 44 + ...letionConfigCompletionconfigFieldmask.java | 41 + .../updatecatalog/SyncUpdateCatalog.java | 46 + .../completequery/AsyncCompleteQuery.java | 54 + .../completequery/SyncCompleteQuery.java | 50 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncImportCompletionData.java | 50 + .../AsyncImportCompletionDataLRO.java | 51 + .../SyncImportCompletionData.java | 47 + .../completequery/SyncCompleteQuery.java | 46 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createcontrol/AsyncCreateControl.java | 48 + .../createcontrol/SyncCreateControl.java | 45 + ...CreateControlCatalognameControlString.java | 41 + .../SyncCreateControlStringControlString.java | 41 + .../deletecontrol/AsyncDeleteControl.java | 47 + .../deletecontrol/SyncDeleteControl.java | 44 + .../SyncDeleteControlControlname.java | 39 + .../SyncDeleteControlString.java | 39 + .../getcontrol/AsyncGetControl.java | 47 + .../getcontrol/SyncGetControl.java | 44 + .../getcontrol/SyncGetControlControlname.java | 39 + .../getcontrol/SyncGetControlString.java | 39 + .../listcontrols/AsyncListControls.java | 52 + .../listcontrols/AsyncListControlsPaged.java | 59 + .../listcontrols/SyncListControls.java | 48 + .../SyncListControlsCatalogname.java | 41 + .../listcontrols/SyncListControlsString.java | 41 + .../updatecontrol/AsyncUpdateControl.java | 47 + .../updatecontrol/SyncUpdateControl.java | 44 + .../SyncUpdateControlControlFieldmask.java | 40 + .../createcontrol/SyncCreateControl.java | 46 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../predict/AsyncPredict.java | 56 + .../predict/SyncPredict.java | 52 + .../predict/SyncPredict.java | 46 + .../AsyncAddFulfillmentPlaces.java | 55 + .../AsyncAddFulfillmentPlacesLRO.java | 56 + .../SyncAddFulfillmentPlaces.java | 52 + .../SyncAddFulfillmentPlacesProductname.java | 41 + .../SyncAddFulfillmentPlacesString.java | 42 + .../AsyncAddLocalInventories.java | 57 + .../AsyncAddLocalInventoriesLRO.java | 58 + .../SyncAddLocalInventories.java | 54 + .../SyncAddLocalInventoriesProductname.java | 41 + .../SyncAddLocalInventoriesString.java | 42 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createproduct/AsyncCreateProduct.java | 49 + .../createproduct/SyncCreateProduct.java | 46 + ...cCreateProductBranchnameProductString.java | 41 + .../SyncCreateProductStringProductString.java | 41 + .../deleteproduct/AsyncDeleteProduct.java | 48 + .../deleteproduct/SyncDeleteProduct.java | 45 + .../SyncDeleteProductProductname.java | 40 + .../SyncDeleteProductString.java | 41 + .../getproduct/AsyncGetProduct.java | 48 + .../getproduct/SyncGetProduct.java | 45 + .../getproduct/SyncGetProductProductname.java | 40 + .../getproduct/SyncGetProductString.java | 41 + .../importproducts/AsyncImportProducts.java | 56 + .../AsyncImportProductsLRO.java | 57 + .../importproducts/SyncImportProducts.java | 52 + .../listproducts/AsyncListProducts.java | 55 + .../listproducts/AsyncListProductsPaged.java | 62 + .../listproducts/SyncListProducts.java | 51 + .../SyncListProductsBranchname.java | 41 + .../listproducts/SyncListProductsString.java | 41 + .../AsyncRemoveFulfillmentPlaces.java | 55 + .../AsyncRemoveFulfillmentPlacesLRO.java | 56 + .../SyncRemoveFulfillmentPlaces.java | 52 + ...yncRemoveFulfillmentPlacesProductname.java | 41 + .../SyncRemoveFulfillmentPlacesString.java | 42 + .../AsyncRemoveLocalInventories.java | 54 + .../AsyncRemoveLocalInventoriesLRO.java | 55 + .../SyncRemoveLocalInventories.java | 51 + ...SyncRemoveLocalInventoriesProductname.java | 41 + .../SyncRemoveLocalInventoriesString.java | 42 + .../setinventory/AsyncSetInventory.java | 51 + .../setinventory/AsyncSetInventoryLRO.java | 53 + .../setinventory/SyncSetInventory.java | 48 + .../SyncSetInventoryProductFieldmask.java | 42 + .../updateproduct/AsyncUpdateProduct.java | 48 + .../updateproduct/SyncUpdateProduct.java | 45 + .../SyncUpdateProductProductFieldmask.java | 40 + .../createproduct/SyncCreateProduct.java | 46 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../search/AsyncSearch.java | 69 + .../search/AsyncSearchPaged.java | 75 + .../search/SyncSearch.java | 65 + .../search/SyncSearch.java | 45 + .../addcontrol/AsyncAddControl.java | 51 + .../addcontrol/SyncAddControl.java | 47 + .../SyncAddControlServingconfigname.java | 41 + .../addcontrol/SyncAddControlString.java | 42 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateServingConfig.java | 50 + .../SyncCreateServingConfig.java | 46 + ...gConfigCatalognameServingconfigString.java | 43 + ...ervingConfigStringServingconfigString.java | 43 + .../AsyncDeleteServingConfig.java | 50 + .../SyncDeleteServingConfig.java | 46 + ...cDeleteServingConfigServingconfigname.java | 41 + .../SyncDeleteServingConfigString.java | 42 + .../AsyncGetServingConfig.java | 50 + .../SyncGetServingConfig.java | 46 + ...SyncGetServingConfigServingconfigname.java | 41 + .../SyncGetServingConfigString.java | 42 + .../AsyncListServingConfigs.java | 52 + .../AsyncListServingConfigsPaged.java | 60 + .../SyncListServingConfigs.java | 49 + .../SyncListServingConfigsCatalogname.java | 43 + .../SyncListServingConfigsString.java | 43 + .../removecontrol/AsyncRemoveControl.java | 51 + .../removecontrol/SyncRemoveControl.java | 47 + .../SyncRemoveControlServingconfigname.java | 41 + .../SyncRemoveControlString.java | 42 + .../AsyncUpdateServingConfig.java | 49 + .../SyncUpdateServingConfig.java | 45 + ...teServingConfigServingconfigFieldmask.java | 42 + .../SyncCreateServingConfig.java | 47 + .../updatecatalog/SyncUpdateCatalog.java | 46 + .../completequery/SyncCompleteQuery.java | 47 + .../createcontrol/SyncCreateControl.java | 46 + .../predict/SyncPredict.java | 47 + .../createproduct/SyncCreateProduct.java | 46 + .../search/SyncSearch.java | 46 + .../SyncCreateServingConfig.java | 47 + .../writeuserevent/SyncWriteUserEvent.java | 46 + .../AsyncCollectUserEvent.java | 49 + .../SyncCollectUserEvent.java | 45 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncImportUserEvents.java | 51 + .../AsyncImportUserEventsLRO.java | 52 + .../SyncImportUserEvents.java | 48 + .../purgeuserevents/AsyncPurgeUserEvents.java | 48 + .../AsyncPurgeUserEventsLRO.java | 49 + .../purgeuserevents/SyncPurgeUserEvents.java | 44 + .../AsyncRejoinUserEvents.java | 44 + .../AsyncRejoinUserEventsLRO.java | 45 + .../SyncRejoinUserEvents.java | 41 + .../writeuserevent/AsyncWriteUserEvent.java | 47 + .../writeuserevent/SyncWriteUserEvent.java | 43 + .../writeuserevent/SyncWriteUserEvent.java | 46 + 650 files changed, 49661 insertions(+), 166 deletions(-) create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceCallableFactory.java create mode 100644 java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceStub.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CatalogServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CompletionServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/PredictionServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/ProductServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/SearchServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/UserEventServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CatalogServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CompletionServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ControlServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/PredictionServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ProductServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/SearchServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/UserEventServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CatalogServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CompletionServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ControlServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/PredictionServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ProductServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/SearchServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ServingConfigServiceClientHttpJsonTest.java create mode 100644 java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/UserEventServiceClientHttpJsonTest.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/AsyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/SyncImportCompletionData.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionservicesettings/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/AsyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionservicesettings/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/AsyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductStringProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/AsyncDeleteProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/AsyncGetProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProductsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/SyncImportProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProductsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsBranchname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventory.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventoryLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventory.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/AsyncUpdateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productservicesettings/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearchPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchservicesettings/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/predictionservicestubsettings/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/productservicestubsettings/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/searchservicestubsettings/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/SyncImportUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/AsyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/SyncImportCompletionData.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionservicesettings/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/AsyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/AsyncDeleteControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/AsyncGetControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlControlname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControls.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControlsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControls.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/AsyncUpdateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlservicesettings/createcontrol/SyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/AsyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionservicesettings/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/AsyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductStringProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/AsyncDeleteProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/AsyncGetProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProductsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/SyncImportProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProductsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsBranchname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProductsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/SyncPurgeProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventory.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventoryLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventory.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/AsyncUpdateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productservicesettings/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearchPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchservicesettings/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/AsyncAddControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/predictionservicestubsettings/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/productservicestubsettings/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/searchservicestubsettings/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/SyncImportUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/AsyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/SyncImportCompletionData.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionservicesettings/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/AsyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/AsyncDeleteControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/AsyncGetControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlControlname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControls.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControlsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControls.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/AsyncUpdateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlservicesettings/createcontrol/SyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/AsyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionservicesettings/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/AsyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductStringProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/AsyncDeleteProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/AsyncGetProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProductsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/SyncImportProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProductsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProducts.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsBranchname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventory.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventoryLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventory.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/AsyncUpdateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productservicesettings/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearchPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchservicesettings/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/AsyncAddControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/predictionservicestubsettings/predict/SyncPredict.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/productservicestubsettings/createproduct/SyncCreateProduct.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/searchservicestubsettings/search/SyncSearch.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/SyncImportUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java create mode 100644 java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java diff --git a/java-retail/README.md b/java-retail/README.md index 9ccf8020307f..bb0be0e3cfc7 100644 --- a/java-retail/README.md +++ b/java-retail/README.md @@ -27,13 +27,13 @@ If you are using Maven, add this to your pom.xml file: If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-retail:2.2.3' +implementation 'com.google.cloud:google-cloud-retail:2.2.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-retail" % "2.2.3" +libraryDependencies += "com.google.cloud" % "google-cloud-retail" % "2.2.4" ``` ## Authentication diff --git a/java-retail/google-cloud-retail/pom.xml b/java-retail/google-cloud-retail/pom.xml index 00c7a3076dd1..eb623472909f 100644 --- a/java-retail/google-cloud-retail/pom.xml +++ b/java-retail/google-cloud-retail/pom.xml @@ -65,6 +65,10 @@ com.google.api gax-grpc + + + com.google.api + gax-httpjson org.threeten @@ -95,12 +99,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java index 9bfd5a37ea7a..862bd411d6de 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceClient.java @@ -99,6 +99,20 @@ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * CatalogServiceSettings catalogServiceSettings =
+ *     CatalogServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java index c4ae476d5ae8..6abdbf47cdbe 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CatalogServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -119,11 +120,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CatalogServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return CatalogServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CatalogServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CatalogServiceStubSettings.defaultTransportChannelProvider(); } @@ -133,11 +141,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CatalogServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -175,6 +189,11 @@ private static Builder createDefault() { return new Builder(CatalogServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CatalogServiceStubSettings.newHttpJsonBuilder()); + } + public CatalogServiceStubSettings.Builder getStubSettingsBuilder() { return ((CatalogServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java index 532803e684e7..343a76990ca6 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceClient.java @@ -17,13 +17,13 @@ package com.google.cloud.retail.v2; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.retail.v2.stub.CompletionServiceStub; import com.google.cloud.retail.v2.stub.CompletionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -107,13 +107,29 @@ * CompletionServiceClient.create(completionServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * CompletionServiceSettings completionServiceSettings =
+ *     CompletionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CompletionServiceClient completionServiceClient =
+ *     CompletionServiceClient.create(completionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class CompletionServiceClient implements BackgroundResource { private final CompletionServiceSettings settings; private final CompletionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CompletionServiceClient with default settings. */ public static final CompletionServiceClient create() throws IOException { @@ -145,13 +161,17 @@ public static final CompletionServiceClient create(CompletionServiceStub stub) { protected CompletionServiceClient(CompletionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((CompletionServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected CompletionServiceClient(CompletionServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final CompletionServiceSettings getSettings() { @@ -166,10 +186,18 @@ public CompletionServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Completes the specified prefix with keyword suggestions. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.java index af4c148597c9..8eec040c1896 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/CompletionServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -113,11 +114,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CompletionServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return CompletionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CompletionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CompletionServiceStubSettings.defaultTransportChannelProvider(); } @@ -127,11 +135,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CompletionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -169,6 +183,11 @@ private static Builder createDefault() { return new Builder(CompletionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CompletionServiceStubSettings.newHttpJsonBuilder()); + } + public CompletionServiceStubSettings.Builder getStubSettingsBuilder() { return ((CompletionServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java index e29e87113a24..6562b4e8e36b 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceClient.java @@ -101,6 +101,21 @@ * PredictionServiceClient.create(predictionServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PredictionServiceSettings predictionServiceSettings =
+ *     PredictionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * PredictionServiceClient predictionServiceClient =
+ *     PredictionServiceClient.create(predictionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.java index acd28f39f75a..0213704fe4bb 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/PredictionServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -98,11 +99,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PredictionServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PredictionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PredictionServiceStubSettings.defaultTransportChannelProvider(); } @@ -112,11 +120,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PredictionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -154,6 +168,11 @@ private static Builder createDefault() { return new Builder(PredictionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PredictionServiceStubSettings.newHttpJsonBuilder()); + } + public PredictionServiceStubSettings.Builder getStubSettingsBuilder() { return ((PredictionServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java index cc9e7a2a2fe5..a97dbdb6d851 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.retail.v2.stub.ProductServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -105,13 +105,28 @@ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ProductServiceSettings productServiceSettings =
+ *     ProductServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ProductServiceClient implements BackgroundResource { private final ProductServiceSettings settings; private final ProductServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductServiceClient with default settings. */ public static final ProductServiceClient create() throws IOException { @@ -143,13 +158,17 @@ public static final ProductServiceClient create(ProductServiceStub stub) { protected ProductServiceClient(ProductServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ProductServiceClient(ProductServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ProductServiceSettings getSettings() { @@ -164,10 +183,18 @@ public ProductServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a [Product][google.cloud.retail.v2.Product]. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java index 8e4f742f3555..246c88c400bc 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/ProductServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -203,11 +204,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ProductServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductServiceStubSettings.defaultTransportChannelProvider(); } @@ -217,11 +225,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -259,6 +273,11 @@ private static Builder createDefault() { return new Builder(ProductServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductServiceStubSettings.newHttpJsonBuilder()); + } + public ProductServiceStubSettings.Builder getStubSettingsBuilder() { return ((ProductServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java index 05006228b0eb..f3f3a5280c7f 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceClient.java @@ -124,6 +124,20 @@ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SearchServiceSettings searchServiceSettings =
+ *     SearchServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java index 4ed2515b601e..4a7ec04e19dc 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/SearchServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -100,11 +101,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SearchServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SearchServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SearchServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SearchServiceStubSettings.defaultTransportChannelProvider(); } @@ -114,11 +122,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SearchServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -156,6 +170,11 @@ private static Builder createDefault() { return new Builder(SearchServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SearchServiceStubSettings.newHttpJsonBuilder()); + } + public SearchServiceStubSettings.Builder getStubSettingsBuilder() { return ((SearchServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java index 0303d6737547..2c92c83d32da 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.HttpBody; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.retail.v2.stub.UserEventServiceStub; import com.google.cloud.retail.v2.stub.UserEventServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -100,13 +100,29 @@ * UserEventServiceClient.create(userEventServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * UserEventServiceSettings userEventServiceSettings =
+ *     UserEventServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * UserEventServiceClient userEventServiceClient =
+ *     UserEventServiceClient.create(userEventServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class UserEventServiceClient implements BackgroundResource { private final UserEventServiceSettings settings; private final UserEventServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of UserEventServiceClient with default settings. */ public static final UserEventServiceClient create() throws IOException { @@ -138,13 +154,17 @@ public static final UserEventServiceClient create(UserEventServiceStub stub) { protected UserEventServiceClient(UserEventServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((UserEventServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected UserEventServiceClient(UserEventServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final UserEventServiceSettings getSettings() { @@ -159,10 +179,18 @@ public UserEventServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Writes a single user event. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java index 051c8cb4478d..51560da9da18 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/UserEventServiceSettings.java @@ -22,6 +22,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -140,11 +141,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return UserEventServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return UserEventServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return UserEventServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return UserEventServiceStubSettings.defaultTransportChannelProvider(); } @@ -154,11 +162,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return UserEventServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -196,6 +210,11 @@ private static Builder createDefault() { return new Builder(UserEventServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(UserEventServiceStubSettings.newHttpJsonBuilder()); + } + public UserEventServiceStubSettings.Builder getStubSettingsBuilder() { return ((UserEventServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java index 1944da11adb6..0da1d1a23ea3 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CatalogServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -186,6 +189,11 @@ public CatalogServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCatalogServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCatalogServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -218,18 +226,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) @@ -237,11 +252,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CatalogServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -355,6 +389,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listCatalogsSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java index f5f4d03a6844..0ccd8074cdaa 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStub.java @@ -38,7 +38,11 @@ public abstract class CompletionServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable completeQueryCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.java index c95aba06bb6a..09f076fdee47 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/CompletionServiceStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -122,6 +125,11 @@ public CompletionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCompletionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCompletionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -154,18 +162,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(CompletionServiceStubSettings.class)) @@ -173,11 +188,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(CompletionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CompletionServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -283,6 +317,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .completeQuerySettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceCallableFactory.java new file mode 100644 index 000000000000..1cdee1ceb4da --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the CatalogService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCatalogServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceStub.java new file mode 100644 index 000000000000..5a2088da34ba --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCatalogServiceStub.java @@ -0,0 +1,365 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import static com.google.cloud.retail.v2.CatalogServiceClient.ListCatalogsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.GetDefaultBranchRequest; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.ListCatalogsResponse; +import com.google.cloud.retail.v2.SetDefaultBranchRequest; +import com.google.cloud.retail.v2.UpdateCatalogRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the CatalogService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCatalogServiceStub extends CatalogServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listCatalogsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/ListCatalogs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*}/catalogs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCatalogsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCatalogMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/UpdateCatalog") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog.name=projects/*/locations/*/catalogs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "catalog.name", request.getCatalog().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("catalog", request.getCatalog())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Catalog.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/SetDefaultBranch") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearCatalog().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CatalogService/GetDefaultBranch") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GetDefaultBranchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listCatalogsCallable; + private final UnaryCallable + listCatalogsPagedCallable; + private final UnaryCallable updateCatalogCallable; + private final UnaryCallable setDefaultBranchCallable; + private final UnaryCallable + getDefaultBranchCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCatalogServiceStub create(CatalogServiceStubSettings settings) + throws IOException { + return new HttpJsonCatalogServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCatalogServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCatalogServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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. + */ + protected HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCatalogServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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. + */ + protected HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listCatalogsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCatalogsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateCatalogTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCatalogMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listCatalogsCallable = + callableFactory.createUnaryCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.listCatalogsPagedCallable = + callableFactory.createPagedCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.updateCatalogCallable = + callableFactory.createUnaryCallable( + updateCatalogTransportSettings, settings.updateCatalogSettings(), clientContext); + this.setDefaultBranchCallable = + callableFactory.createUnaryCallable( + setDefaultBranchTransportSettings, settings.setDefaultBranchSettings(), clientContext); + this.getDefaultBranchCallable = + callableFactory.createUnaryCallable( + getDefaultBranchTransportSettings, settings.getDefaultBranchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listCatalogsMethodDescriptor); + methodDescriptors.add(updateCatalogMethodDescriptor); + methodDescriptors.add(setDefaultBranchMethodDescriptor); + methodDescriptors.add(getDefaultBranchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listCatalogsCallable() { + return listCatalogsCallable; + } + + @Override + public UnaryCallable listCatalogsPagedCallable() { + return listCatalogsPagedCallable; + } + + @Override + public UnaryCallable updateCatalogCallable() { + return updateCatalogCallable; + } + + @Override + public UnaryCallable setDefaultBranchCallable() { + return setDefaultBranchCallable; + } + + @Override + public UnaryCallable + getDefaultBranchCallable() { + return getDefaultBranchCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceCallableFactory.java new file mode 100644 index 000000000000..15c6a41f04ff --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the CompletionService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCompletionServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceStub.java new file mode 100644 index 000000000000..cb0dbd5304bf --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonCompletionServiceStub.java @@ -0,0 +1,291 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2.CompleteQueryRequest; +import com.google.cloud.retail.v2.CompleteQueryResponse; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.cloud.retail.v2.ImportCompletionDataResponse; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the CompletionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCompletionServiceStub extends CompletionServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportCompletionDataResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + completeQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CompletionService/CompleteQuery") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "dataset", request.getDataset()); + serializer.putQueryParam(fields, "deviceType", request.getDeviceType()); + serializer.putQueryParam( + fields, "languageCodes", request.getLanguageCodesList()); + serializer.putQueryParam( + fields, "maxSuggestions", request.getMaxSuggestions()); + serializer.putQueryParam(fields, "query", request.getQuery()); + serializer.putQueryParam(fields, "visitorId", request.getVisitorId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompleteQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importCompletionDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.CompletionService/ImportCompletionData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportCompletionDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable completeQueryCallable; + private final UnaryCallable importCompletionDataCallable; + private final OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCompletionServiceStub create(CompletionServiceStubSettings settings) + throws IOException { + return new HttpJsonCompletionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCompletionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCompletionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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. + */ + protected HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCompletionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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. + */ + protected HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + completeQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + importCompletionDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importCompletionDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.completeQueryCallable = + callableFactory.createUnaryCallable( + completeQueryTransportSettings, settings.completeQuerySettings(), clientContext); + this.importCompletionDataCallable = + callableFactory.createUnaryCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataSettings(), + clientContext); + this.importCompletionDataOperationCallable = + callableFactory.createOperationCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(completeQueryMethodDescriptor); + methodDescriptors.add(importCompletionDataMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable completeQueryCallable() { + return completeQueryCallable; + } + + @Override + public UnaryCallable importCompletionDataCallable() { + return importCompletionDataCallable; + } + + @Override + public OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable() { + return importCompletionDataOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 000000000000..fca54521c7ad --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the PredictionService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPredictionServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 000000000000..e9f4a1d9f173 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,194 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2.PredictRequest; +import com.google.cloud.retail.v2.PredictResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the PredictionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPredictionServiceStub extends PredictionServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable predictCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPredictionServiceStub create(PredictionServiceStubSettings settings) + throws IOException { + return new HttpJsonPredictionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPredictionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPredictionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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. + */ + protected HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonPredictionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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. + */ + protected HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceCallableFactory.java new file mode 100644 index 000000000000..f27eead28f22 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ProductService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProductServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceStub.java new file mode 100644 index 000000000000..b8cf0324b9f6 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonProductServiceStub.java @@ -0,0 +1,895 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import static com.google.cloud.retail.v2.ProductServiceClient.ListProductsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.CreateProductRequest; +import com.google.cloud.retail.v2.DeleteProductRequest; +import com.google.cloud.retail.v2.GetProductRequest; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ImportProductsResponse; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.ListProductsResponse; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; +import com.google.cloud.retail.v2.SetInventoryMetadata; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.cloud.retail.v2.UpdateProductRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ProductService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProductServiceStub extends ProductServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RemoveLocalInventoriesMetadata.getDescriptor()) + .add(AddLocalInventoriesMetadata.getDescriptor()) + .add(AddFulfillmentPlacesMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesMetadata.getDescriptor()) + .add(SetInventoryResponse.getDescriptor()) + .add(AddLocalInventoriesResponse.getDescriptor()) + .add(ImportProductsResponse.getDescriptor()) + .add(RemoveFulfillmentPlacesResponse.getDescriptor()) + .add(RemoveLocalInventoriesResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(AddFulfillmentPlacesResponse.getDescriptor()) + .add(SetInventoryMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "productId", request.getProductId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readMask", request.getReadMask()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "product.name", request.getProduct().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "allowMissing", request.getAllowMissing()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/ImportProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/SetInventory") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "inventory.name", request.getInventory().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (SetInventoryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/AddFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/RemoveFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/AddLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.ProductService/RemoveLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable importProductsCallable; + private final OperationCallable + importProductsOperationCallable; + private final UnaryCallable setInventoryCallable; + private final OperationCallable + setInventoryOperationCallable; + private final UnaryCallable addFulfillmentPlacesCallable; + private final OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable; + private final UnaryCallable + removeFulfillmentPlacesCallable; + private final OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable; + private final UnaryCallable addLocalInventoriesCallable; + private final OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable; + private final UnaryCallable + removeLocalInventoriesCallable; + private final OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductServiceStub create(ProductServiceStubSettings settings) + throws IOException { + return new HttpJsonProductServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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. + */ + protected HttpJsonProductServiceStub( + ProductServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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. + */ + protected HttpJsonProductServiceStub( + ProductServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.importProductsCallable = + callableFactory.createUnaryCallable( + importProductsTransportSettings, settings.importProductsSettings(), clientContext); + this.importProductsOperationCallable = + callableFactory.createOperationCallable( + importProductsTransportSettings, + settings.importProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setInventoryCallable = + callableFactory.createUnaryCallable( + setInventoryTransportSettings, settings.setInventorySettings(), clientContext); + this.setInventoryOperationCallable = + callableFactory.createOperationCallable( + setInventoryTransportSettings, + settings.setInventoryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesSettings(), + clientContext); + this.addFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesSettings(), + clientContext); + this.removeFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addLocalInventoriesCallable = + callableFactory.createUnaryCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesSettings(), + clientContext); + this.addLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeLocalInventoriesCallable = + callableFactory.createUnaryCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesSettings(), + clientContext); + this.removeLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(importProductsMethodDescriptor); + methodDescriptors.add(setInventoryMethodDescriptor); + methodDescriptors.add(addFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(removeFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(addLocalInventoriesMethodDescriptor); + methodDescriptors.add(removeLocalInventoriesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable importProductsCallable() { + return importProductsCallable; + } + + @Override + public OperationCallable + importProductsOperationCallable() { + return importProductsOperationCallable; + } + + @Override + public UnaryCallable setInventoryCallable() { + return setInventoryCallable; + } + + @Override + public OperationCallable + setInventoryOperationCallable() { + return setInventoryOperationCallable; + } + + @Override + public UnaryCallable addFulfillmentPlacesCallable() { + return addFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable() { + return addFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable + removeFulfillmentPlacesCallable() { + return removeFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable() { + return removeFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable addLocalInventoriesCallable() { + return addLocalInventoriesCallable; + } + + @Override + public OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable() { + return addLocalInventoriesOperationCallable; + } + + @Override + public UnaryCallable removeLocalInventoriesCallable() { + return removeLocalInventoriesCallable; + } + + @Override + public OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable() { + return removeLocalInventoriesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceCallableFactory.java new file mode 100644 index 000000000000..1aad89bdbef8 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SearchService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSearchServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceStub.java new file mode 100644 index 000000000000..7caaa74000b1 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonSearchServiceStub.java @@ -0,0 +1,204 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import static com.google.cloud.retail.v2.SearchServiceClient.SearchPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SearchService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSearchServiceStub extends SearchServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor searchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.SearchService/Search") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable searchCallable; + private final UnaryCallable searchPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSearchServiceStub create(SearchServiceStubSettings settings) + throws IOException { + return new HttpJsonSearchServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSearchServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSearchServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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. + */ + protected HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSearchServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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. + */ + protected HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings searchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.searchCallable = + callableFactory.createUnaryCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + this.searchPagedCallable = + callableFactory.createPagedCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(searchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable searchCallable() { + return searchCallable; + } + + @Override + public UnaryCallable searchPagedCallable() { + return searchPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceCallableFactory.java new file mode 100644 index 000000000000..26bd6635c189 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the UserEventService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonUserEventServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceStub.java new file mode 100644 index 000000000000..38e4a9d16ce4 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/HttpJsonUserEventServiceStub.java @@ -0,0 +1,481 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub; + +import com.google.api.HttpBody; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2.CollectUserEventRequest; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.ImportUserEventsResponse; +import com.google.cloud.retail.v2.PurgeMetadata; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.PurgeUserEventsResponse; +import com.google.cloud.retail.v2.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.RejoinUserEventsResponse; +import com.google.cloud.retail.v2.UserEvent; +import com.google.cloud.retail.v2.WriteUserEventRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the UserEventService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonUserEventServiceStub extends UserEventServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportUserEventsResponse.getDescriptor()) + .add(PurgeMetadata.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(RejoinUserEventsResponse.getDescriptor()) + .add(PurgeUserEventsResponse.getDescriptor()) + .add(RejoinUserEventsMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + writeUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/WriteUserEvent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("userEvent", request.getUserEvent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserEvent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + collectUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/CollectUserEvent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "ets", request.getEts()); + serializer.putQueryParam(fields, "uri", request.getUri()); + serializer.putQueryParam(fields, "userEvent", request.getUserEvent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HttpBody.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + purgeUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/PurgeUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (PurgeUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/ImportUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rejoinUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2.UserEventService/RejoinUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RejoinUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable writeUserEventCallable; + private final UnaryCallable collectUserEventCallable; + private final UnaryCallable purgeUserEventsCallable; + private final OperationCallable + purgeUserEventsOperationCallable; + private final UnaryCallable importUserEventsCallable; + private final OperationCallable + importUserEventsOperationCallable; + private final UnaryCallable rejoinUserEventsCallable; + private final OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonUserEventServiceStub create(UserEventServiceStubSettings settings) + throws IOException { + return new HttpJsonUserEventServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonUserEventServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonUserEventServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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. + */ + protected HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonUserEventServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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. + */ + protected HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings writeUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(writeUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings collectUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(collectUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings rejoinUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rejoinUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.writeUserEventCallable = + callableFactory.createUnaryCallable( + writeUserEventTransportSettings, settings.writeUserEventSettings(), clientContext); + this.collectUserEventCallable = + callableFactory.createUnaryCallable( + collectUserEventTransportSettings, settings.collectUserEventSettings(), clientContext); + this.purgeUserEventsCallable = + callableFactory.createUnaryCallable( + purgeUserEventsTransportSettings, settings.purgeUserEventsSettings(), clientContext); + this.purgeUserEventsOperationCallable = + callableFactory.createOperationCallable( + purgeUserEventsTransportSettings, + settings.purgeUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importUserEventsCallable = + callableFactory.createUnaryCallable( + importUserEventsTransportSettings, settings.importUserEventsSettings(), clientContext); + this.importUserEventsOperationCallable = + callableFactory.createOperationCallable( + importUserEventsTransportSettings, + settings.importUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rejoinUserEventsCallable = + callableFactory.createUnaryCallable( + rejoinUserEventsTransportSettings, settings.rejoinUserEventsSettings(), clientContext); + this.rejoinUserEventsOperationCallable = + callableFactory.createOperationCallable( + rejoinUserEventsTransportSettings, + settings.rejoinUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(writeUserEventMethodDescriptor); + methodDescriptors.add(collectUserEventMethodDescriptor); + methodDescriptors.add(purgeUserEventsMethodDescriptor); + methodDescriptors.add(importUserEventsMethodDescriptor); + methodDescriptors.add(rejoinUserEventsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable writeUserEventCallable() { + return writeUserEventCallable; + } + + @Override + public UnaryCallable collectUserEventCallable() { + return collectUserEventCallable; + } + + @Override + public UnaryCallable purgeUserEventsCallable() { + return purgeUserEventsCallable; + } + + @Override + public OperationCallable + purgeUserEventsOperationCallable() { + return purgeUserEventsOperationCallable; + } + + @Override + public UnaryCallable importUserEventsCallable() { + return importUserEventsCallable; + } + + @Override + public OperationCallable + importUserEventsOperationCallable() { + return importUserEventsOperationCallable; + } + + @Override + public UnaryCallable rejoinUserEventsCallable() { + return rejoinUserEventsCallable; + } + + @Override + public OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable() { + return rejoinUserEventsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.java index 6ae5c4b58787..679165b89de2 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/PredictionServiceStubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -96,6 +99,11 @@ public PredictionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPredictionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPredictionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -128,18 +136,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(PredictionServiceStubSettings.class)) @@ -147,11 +162,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(PredictionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PredictionServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -241,6 +275,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .predictSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java index 82101796004f..78dfafd77174 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStub.java @@ -61,7 +61,11 @@ public abstract class ProductServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable createProductCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java index 1887510ca48d..995e113942a7 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/ProductServiceStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -320,6 +323,11 @@ public ProductServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -352,18 +360,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ProductServiceStubSettings.class)) @@ -371,11 +386,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ProductServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -598,6 +632,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createProductSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java index bc8808332d53..f8a89672c464 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/SearchServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -157,6 +160,11 @@ public SearchServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSearchServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSearchServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -189,18 +197,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SearchServiceStubSettings.class)) @@ -208,11 +223,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SearchServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SearchServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -303,6 +337,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .searchSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java index d07944871cf8..9735dcbc9a08 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStub.java @@ -46,7 +46,11 @@ public abstract class UserEventServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable writeUserEventCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java index 6d4f2fd44dce..9b55643855d3 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2/stub/UserEventServiceStubSettings.java @@ -26,6 +26,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -163,6 +166,11 @@ public UserEventServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcUserEventServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonUserEventServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -195,18 +203,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(UserEventServiceStubSettings.class)) @@ -214,11 +229,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(UserEventServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return UserEventServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -389,6 +423,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .writeUserEventSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java index 71de43b540e9..4ba69f59aec4 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceClient.java @@ -100,6 +100,20 @@ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * CatalogServiceSettings catalogServiceSettings =
+ *     CatalogServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java index 5ce90c09261b..a26924067328 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CatalogServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -162,11 +163,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CatalogServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return CatalogServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CatalogServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CatalogServiceStubSettings.defaultTransportChannelProvider(); } @@ -176,11 +184,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CatalogServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -218,6 +232,11 @@ private static Builder createDefault() { return new Builder(CatalogServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CatalogServiceStubSettings.newHttpJsonBuilder()); + } + public CatalogServiceStubSettings.Builder getStubSettingsBuilder() { return ((CatalogServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.java index 116d00b1dbb3..972267fec446 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.retail.v2alpha.stub.CompletionServiceStub; import com.google.cloud.retail.v2alpha.stub.CompletionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -108,6 +108,21 @@ * CompletionServiceClient.create(completionServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * CompletionServiceSettings completionServiceSettings =
+ *     CompletionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CompletionServiceClient completionServiceClient =
+ *     CompletionServiceClient.create(completionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -115,7 +130,8 @@ public class CompletionServiceClient implements BackgroundResource { private final CompletionServiceSettings settings; private final CompletionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CompletionServiceClient with default settings. */ public static final CompletionServiceClient create() throws IOException { @@ -147,13 +163,17 @@ public static final CompletionServiceClient create(CompletionServiceStub stub) { protected CompletionServiceClient(CompletionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((CompletionServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected CompletionServiceClient(CompletionServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final CompletionServiceSettings getSettings() { @@ -168,10 +188,18 @@ public CompletionServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Completes the specified prefix with keyword suggestions. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.java index ee307daab4e0..b9d4cc2a6444 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/CompletionServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -114,11 +115,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CompletionServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return CompletionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CompletionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CompletionServiceStubSettings.defaultTransportChannelProvider(); } @@ -128,11 +136,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CompletionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -170,6 +184,11 @@ private static Builder createDefault() { return new Builder(CompletionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CompletionServiceStubSettings.newHttpJsonBuilder()); + } + public CompletionServiceStubSettings.Builder getStubSettingsBuilder() { return ((CompletionServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java index d5270698e06e..54b7dba91590 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceClient.java @@ -101,6 +101,20 @@ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ControlServiceSettings controlServiceSettings =
+ *     ControlServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java index 8bad2cb5a481..b15aac0dc432 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ControlServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -124,11 +125,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ControlServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ControlServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ControlServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ControlServiceStubSettings.defaultTransportChannelProvider(); } @@ -138,11 +146,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ControlServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -180,6 +194,11 @@ private static Builder createDefault() { return new Builder(ControlServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ControlServiceStubSettings.newHttpJsonBuilder()); + } + public ControlServiceStubSettings.Builder getStubSettingsBuilder() { return ((ControlServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java index bbf984a95a32..c4126cd1e636 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceClient.java @@ -102,6 +102,21 @@ * PredictionServiceClient.create(predictionServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PredictionServiceSettings predictionServiceSettings =
+ *     PredictionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * PredictionServiceClient predictionServiceClient =
+ *     PredictionServiceClient.create(predictionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.java index 62ced44d63c9..60d2a1e40609 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/PredictionServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -99,11 +100,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PredictionServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PredictionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PredictionServiceStubSettings.defaultTransportChannelProvider(); } @@ -113,11 +121,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PredictionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -155,6 +169,11 @@ private static Builder createDefault() { return new Builder(PredictionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PredictionServiceStubSettings.newHttpJsonBuilder()); + } + public PredictionServiceStubSettings.Builder getStubSettingsBuilder() { return ((PredictionServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.java index b03e91577936..0871c9c89e55 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.retail.v2alpha.stub.ProductServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -106,6 +106,20 @@ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ProductServiceSettings productServiceSettings =
+ *     ProductServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -113,7 +127,8 @@ public class ProductServiceClient implements BackgroundResource { private final ProductServiceSettings settings; private final ProductServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductServiceClient with default settings. */ public static final ProductServiceClient create() throws IOException { @@ -145,13 +160,17 @@ public static final ProductServiceClient create(ProductServiceStub stub) { protected ProductServiceClient(ProductServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ProductServiceClient(ProductServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ProductServiceSettings getSettings() { @@ -166,10 +185,18 @@ public ProductServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a [Product][google.cloud.retail.v2alpha.Product]. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java index d65553f0c2d3..de3e6fbfbcac 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ProductServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -215,11 +216,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ProductServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductServiceStubSettings.defaultTransportChannelProvider(); } @@ -229,11 +237,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -271,6 +285,11 @@ private static Builder createDefault() { return new Builder(ProductServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductServiceStubSettings.newHttpJsonBuilder()); + } + public ProductServiceStubSettings.Builder getStubSettingsBuilder() { return ((ProductServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java index cb32d6585fd2..4a99248fd313 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceClient.java @@ -123,6 +123,20 @@ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SearchServiceSettings searchServiceSettings =
+ *     SearchServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java index 4b64c5c61e31..bb53ae37f12f 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/SearchServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -101,11 +102,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SearchServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SearchServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SearchServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SearchServiceStubSettings.defaultTransportChannelProvider(); } @@ -115,11 +123,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SearchServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -157,6 +171,11 @@ private static Builder createDefault() { return new Builder(SearchServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SearchServiceStubSettings.newHttpJsonBuilder()); + } + public SearchServiceStubSettings.Builder getStubSettingsBuilder() { return ((SearchServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java index df630afa02f3..c4d433e31a2c 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClient.java @@ -106,6 +106,21 @@ * ServingConfigServiceClient.create(servingConfigServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ServingConfigServiceSettings servingConfigServiceSettings =
+ *     ServingConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ServingConfigServiceClient servingConfigServiceClient =
+ *     ServingConfigServiceClient.create(servingConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java index d829c944fd2e..b6c0cb663dd0 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/ServingConfigServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -138,11 +139,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ServingConfigServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ServingConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ServingConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ServingConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -152,11 +160,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ServingConfigServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -195,6 +209,11 @@ private static Builder createDefault() { return new Builder(ServingConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ServingConfigServiceStubSettings.newHttpJsonBuilder()); + } + public ServingConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((ServingConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java index e964d5719264..047bf8634727 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceClient.java @@ -19,13 +19,13 @@ import com.google.api.HttpBody; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.retail.v2alpha.stub.UserEventServiceStub; import com.google.cloud.retail.v2alpha.stub.UserEventServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -101,6 +101,21 @@ * UserEventServiceClient.create(userEventServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * UserEventServiceSettings userEventServiceSettings =
+ *     UserEventServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * UserEventServiceClient userEventServiceClient =
+ *     UserEventServiceClient.create(userEventServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -108,7 +123,8 @@ public class UserEventServiceClient implements BackgroundResource { private final UserEventServiceSettings settings; private final UserEventServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of UserEventServiceClient with default settings. */ public static final UserEventServiceClient create() throws IOException { @@ -140,13 +156,17 @@ public static final UserEventServiceClient create(UserEventServiceStub stub) { protected UserEventServiceClient(UserEventServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((UserEventServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected UserEventServiceClient(UserEventServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final UserEventServiceSettings getSettings() { @@ -161,10 +181,18 @@ public UserEventServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Writes a single user event. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java index 4e413e8027a8..a64701384a45 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/UserEventServiceSettings.java @@ -22,6 +22,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -141,11 +142,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return UserEventServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return UserEventServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return UserEventServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return UserEventServiceStubSettings.defaultTransportChannelProvider(); } @@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return UserEventServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -197,6 +211,11 @@ private static Builder createDefault() { return new Builder(UserEventServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(UserEventServiceStubSettings.newHttpJsonBuilder()); + } + public UserEventServiceStubSettings.Builder getStubSettingsBuilder() { return ((UserEventServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java index 818c66a5da98..b5542b5e54f3 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CatalogServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -252,6 +255,11 @@ public CatalogServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCatalogServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCatalogServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -284,18 +292,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) @@ -303,11 +318,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CatalogServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -470,6 +504,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listCatalogsSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java index 7b2bd81a89d8..e3cabeca6b30 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStub.java @@ -40,7 +40,11 @@ public abstract class CompletionServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable completeQueryCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.java index 6e9392558d14..413700f26d6f 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/CompletionServiceStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -123,6 +126,11 @@ public CompletionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCompletionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCompletionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -155,18 +163,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(CompletionServiceStubSettings.class)) @@ -174,11 +189,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(CompletionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CompletionServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -284,6 +318,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .completeQuerySettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java index d58eafd21f19..c42ca1383097 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ControlServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -190,6 +193,11 @@ public ControlServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcControlServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonControlServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -222,18 +230,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ControlServiceStubSettings.class)) @@ -241,11 +256,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ControlServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ControlServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -350,6 +384,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createControlSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceCallableFactory.java new file mode 100644 index 000000000000..66ae664731aa --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the CatalogService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceStub.java new file mode 100644 index 000000000000..aaf8a44a01fe --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCatalogServiceStub.java @@ -0,0 +1,772 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.CatalogServiceClient.ListCatalogsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.GetAttributesConfigRequest; +import com.google.cloud.retail.v2alpha.GetCompletionConfigRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.ListCatalogsResponse; +import com.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.SetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; +import com.google.cloud.retail.v2alpha.UpdateCatalogRequest; +import com.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the CatalogService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceStub extends CatalogServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listCatalogsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/ListCatalogs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*}/catalogs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCatalogsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCatalogMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/UpdateCatalog") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "catalog.name", request.getCatalog().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("catalog", request.getCatalog())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Catalog.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/SetDefaultBranch") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearCatalog().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetDefaultBranch") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GetDefaultBranchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetCompletionConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/UpdateCompletionConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{completionConfig.name=projects/*/locations/*/catalogs/*/completionConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "completionConfig.name", + request.getCompletionConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("completionConfig", request.getCompletionConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetAttributesConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/UpdateAttributesConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig.name=projects/*/locations/*/catalogs/*/attributesConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "attributesConfig.name", + request.getAttributesConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("attributesConfig", request.getAttributesConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/AddCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/RemoveCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + replaceCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CatalogService/ReplaceCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listCatalogsCallable; + private final UnaryCallable + listCatalogsPagedCallable; + private final UnaryCallable updateCatalogCallable; + private final UnaryCallable setDefaultBranchCallable; + private final UnaryCallable + getDefaultBranchCallable; + private final UnaryCallable + getCompletionConfigCallable; + private final UnaryCallable + updateCompletionConfigCallable; + private final UnaryCallable + getAttributesConfigCallable; + private final UnaryCallable + updateAttributesConfigCallable; + private final UnaryCallable + addCatalogAttributeCallable; + private final UnaryCallable + removeCatalogAttributeCallable; + private final UnaryCallable + replaceCatalogAttributeCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCatalogServiceStub create(CatalogServiceStubSettings settings) + throws IOException { + return new HttpJsonCatalogServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCatalogServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCatalogServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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. + */ + protected HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCatalogServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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. + */ + protected HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listCatalogsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCatalogsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateCatalogTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCatalogMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + replaceCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(replaceCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listCatalogsCallable = + callableFactory.createUnaryCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.listCatalogsPagedCallable = + callableFactory.createPagedCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.updateCatalogCallable = + callableFactory.createUnaryCallable( + updateCatalogTransportSettings, settings.updateCatalogSettings(), clientContext); + this.setDefaultBranchCallable = + callableFactory.createUnaryCallable( + setDefaultBranchTransportSettings, settings.setDefaultBranchSettings(), clientContext); + this.getDefaultBranchCallable = + callableFactory.createUnaryCallable( + getDefaultBranchTransportSettings, settings.getDefaultBranchSettings(), clientContext); + this.getCompletionConfigCallable = + callableFactory.createUnaryCallable( + getCompletionConfigTransportSettings, + settings.getCompletionConfigSettings(), + clientContext); + this.updateCompletionConfigCallable = + callableFactory.createUnaryCallable( + updateCompletionConfigTransportSettings, + settings.updateCompletionConfigSettings(), + clientContext); + this.getAttributesConfigCallable = + callableFactory.createUnaryCallable( + getAttributesConfigTransportSettings, + settings.getAttributesConfigSettings(), + clientContext); + this.updateAttributesConfigCallable = + callableFactory.createUnaryCallable( + updateAttributesConfigTransportSettings, + settings.updateAttributesConfigSettings(), + clientContext); + this.addCatalogAttributeCallable = + callableFactory.createUnaryCallable( + addCatalogAttributeTransportSettings, + settings.addCatalogAttributeSettings(), + clientContext); + this.removeCatalogAttributeCallable = + callableFactory.createUnaryCallable( + removeCatalogAttributeTransportSettings, + settings.removeCatalogAttributeSettings(), + clientContext); + this.replaceCatalogAttributeCallable = + callableFactory.createUnaryCallable( + replaceCatalogAttributeTransportSettings, + settings.replaceCatalogAttributeSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listCatalogsMethodDescriptor); + methodDescriptors.add(updateCatalogMethodDescriptor); + methodDescriptors.add(setDefaultBranchMethodDescriptor); + methodDescriptors.add(getDefaultBranchMethodDescriptor); + methodDescriptors.add(getCompletionConfigMethodDescriptor); + methodDescriptors.add(updateCompletionConfigMethodDescriptor); + methodDescriptors.add(getAttributesConfigMethodDescriptor); + methodDescriptors.add(updateAttributesConfigMethodDescriptor); + methodDescriptors.add(addCatalogAttributeMethodDescriptor); + methodDescriptors.add(removeCatalogAttributeMethodDescriptor); + methodDescriptors.add(replaceCatalogAttributeMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listCatalogsCallable() { + return listCatalogsCallable; + } + + @Override + public UnaryCallable listCatalogsPagedCallable() { + return listCatalogsPagedCallable; + } + + @Override + public UnaryCallable updateCatalogCallable() { + return updateCatalogCallable; + } + + @Override + public UnaryCallable setDefaultBranchCallable() { + return setDefaultBranchCallable; + } + + @Override + public UnaryCallable + getDefaultBranchCallable() { + return getDefaultBranchCallable; + } + + @Override + public UnaryCallable getCompletionConfigCallable() { + return getCompletionConfigCallable; + } + + @Override + public UnaryCallable + updateCompletionConfigCallable() { + return updateCompletionConfigCallable; + } + + @Override + public UnaryCallable getAttributesConfigCallable() { + return getAttributesConfigCallable; + } + + @Override + public UnaryCallable + updateAttributesConfigCallable() { + return updateAttributesConfigCallable; + } + + @Override + public UnaryCallable addCatalogAttributeCallable() { + return addCatalogAttributeCallable; + } + + @Override + public UnaryCallable + removeCatalogAttributeCallable() { + return removeCatalogAttributeCallable; + } + + @Override + public UnaryCallable + replaceCatalogAttributeCallable() { + return replaceCatalogAttributeCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceCallableFactory.java new file mode 100644 index 000000000000..2d87d8b60b0e --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the CompletionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceStub.java new file mode 100644 index 000000000000..397adb86254f --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonCompletionServiceStub.java @@ -0,0 +1,292 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.CompleteQueryRequest; +import com.google.cloud.retail.v2alpha.CompleteQueryResponse; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.cloud.retail.v2alpha.ImportCompletionDataResponse; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the CompletionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceStub extends CompletionServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportCompletionDataResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + completeQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.CompletionService/CompleteQuery") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "dataset", request.getDataset()); + serializer.putQueryParam(fields, "deviceType", request.getDeviceType()); + serializer.putQueryParam( + fields, "languageCodes", request.getLanguageCodesList()); + serializer.putQueryParam( + fields, "maxSuggestions", request.getMaxSuggestions()); + serializer.putQueryParam(fields, "query", request.getQuery()); + serializer.putQueryParam(fields, "visitorId", request.getVisitorId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompleteQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importCompletionDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.CompletionService/ImportCompletionData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportCompletionDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable completeQueryCallable; + private final UnaryCallable importCompletionDataCallable; + private final OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCompletionServiceStub create(CompletionServiceStubSettings settings) + throws IOException { + return new HttpJsonCompletionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCompletionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCompletionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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. + */ + protected HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCompletionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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. + */ + protected HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + completeQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + importCompletionDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importCompletionDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.completeQueryCallable = + callableFactory.createUnaryCallable( + completeQueryTransportSettings, settings.completeQuerySettings(), clientContext); + this.importCompletionDataCallable = + callableFactory.createUnaryCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataSettings(), + clientContext); + this.importCompletionDataOperationCallable = + callableFactory.createOperationCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(completeQueryMethodDescriptor); + methodDescriptors.add(importCompletionDataMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable completeQueryCallable() { + return completeQueryCallable; + } + + @Override + public UnaryCallable importCompletionDataCallable() { + return importCompletionDataCallable; + } + + @Override + public OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable() { + return importCompletionDataOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceCallableFactory.java new file mode 100644 index 000000000000..a4bb05d7c00d --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ControlService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceStub.java new file mode 100644 index 000000000000..2dbd5c64e904 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonControlServiceStub.java @@ -0,0 +1,410 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.ControlServiceClient.ListControlsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.CreateControlRequest; +import com.google.cloud.retail.v2alpha.DeleteControlRequest; +import com.google.cloud.retail.v2alpha.GetControlRequest; +import com.google.cloud.retail.v2alpha.ListControlsRequest; +import com.google.cloud.retail.v2alpha.ListControlsResponse; +import com.google.cloud.retail.v2alpha.UpdateControlRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ControlService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceStub extends ControlServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/CreateControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "controlId", request.getControlId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/DeleteControl") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/UpdateControl") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "control.name", request.getControl().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/GetControl") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listControlsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ControlService/ListControls") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListControlsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createControlCallable; + private final UnaryCallable deleteControlCallable; + private final UnaryCallable updateControlCallable; + private final UnaryCallable getControlCallable; + private final UnaryCallable listControlsCallable; + private final UnaryCallable + listControlsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonControlServiceStub create(ControlServiceStubSettings settings) + throws IOException { + return new HttpJsonControlServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonControlServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonControlServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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. + */ + protected HttpJsonControlServiceStub( + ControlServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonControlServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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. + */ + protected HttpJsonControlServiceStub( + ControlServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listControlsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listControlsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createControlCallable = + callableFactory.createUnaryCallable( + createControlTransportSettings, settings.createControlSettings(), clientContext); + this.deleteControlCallable = + callableFactory.createUnaryCallable( + deleteControlTransportSettings, settings.deleteControlSettings(), clientContext); + this.updateControlCallable = + callableFactory.createUnaryCallable( + updateControlTransportSettings, settings.updateControlSettings(), clientContext); + this.getControlCallable = + callableFactory.createUnaryCallable( + getControlTransportSettings, settings.getControlSettings(), clientContext); + this.listControlsCallable = + callableFactory.createUnaryCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + this.listControlsPagedCallable = + callableFactory.createPagedCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createControlMethodDescriptor); + methodDescriptors.add(deleteControlMethodDescriptor); + methodDescriptors.add(updateControlMethodDescriptor); + methodDescriptors.add(getControlMethodDescriptor); + methodDescriptors.add(listControlsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createControlCallable() { + return createControlCallable; + } + + @Override + public UnaryCallable deleteControlCallable() { + return deleteControlCallable; + } + + @Override + public UnaryCallable updateControlCallable() { + return updateControlCallable; + } + + @Override + public UnaryCallable getControlCallable() { + return getControlCallable; + } + + @Override + public UnaryCallable listControlsCallable() { + return listControlsCallable; + } + + @Override + public UnaryCallable listControlsPagedCallable() { + return listControlsPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 000000000000..f289b9366a52 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the PredictionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 000000000000..502fde4e716d --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,194 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.PredictRequest; +import com.google.cloud.retail.v2alpha.PredictResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the PredictionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceStub extends PredictionServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable predictCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPredictionServiceStub create(PredictionServiceStubSettings settings) + throws IOException { + return new HttpJsonPredictionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPredictionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPredictionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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. + */ + protected HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonPredictionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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. + */ + protected HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceCallableFactory.java new file mode 100644 index 000000000000..5255bceb19fd --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ProductService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceStub.java new file mode 100644 index 000000000000..8bfa43718c69 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonProductServiceStub.java @@ -0,0 +1,973 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.ProductServiceClient.ListProductsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.CreateProductRequest; +import com.google.cloud.retail.v2alpha.DeleteProductRequest; +import com.google.cloud.retail.v2alpha.GetProductRequest; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ImportProductsResponse; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.ListProductsResponse; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.PurgeProductsMetadata; +import com.google.cloud.retail.v2alpha.PurgeProductsRequest; +import com.google.cloud.retail.v2alpha.PurgeProductsResponse; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.SetInventoryMetadata; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.cloud.retail.v2alpha.UpdateProductRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ProductService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceStub extends ProductServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RemoveLocalInventoriesResponse.getDescriptor()) + .add(PurgeProductsMetadata.getDescriptor()) + .add(AddFulfillmentPlacesResponse.getDescriptor()) + .add(RemoveFulfillmentPlacesMetadata.getDescriptor()) + .add(SetInventoryResponse.getDescriptor()) + .add(SetInventoryMetadata.getDescriptor()) + .add(AddLocalInventoriesMetadata.getDescriptor()) + .add(PurgeProductsResponse.getDescriptor()) + .add(ImportProductsResponse.getDescriptor()) + .add(AddLocalInventoriesResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(AddFulfillmentPlacesMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesResponse.getDescriptor()) + .add(RemoveLocalInventoriesMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "productId", request.getProductId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readMask", request.getReadMask()); + serializer.putQueryParam( + fields, "requireTotalSize", request.getRequireTotalSize()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "product.name", request.getProduct().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "allowMissing", request.getAllowMissing()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + purgeProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/PurgeProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (PurgeProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/ImportProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/SetInventory") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "inventory.name", request.getInventory().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (SetInventoryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/AddFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ProductService/RemoveFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ProductService/AddLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ProductService/RemoveLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable purgeProductsCallable; + private final OperationCallable< + PurgeProductsRequest, PurgeProductsResponse, PurgeProductsMetadata> + purgeProductsOperationCallable; + private final UnaryCallable importProductsCallable; + private final OperationCallable + importProductsOperationCallable; + private final UnaryCallable setInventoryCallable; + private final OperationCallable + setInventoryOperationCallable; + private final UnaryCallable addFulfillmentPlacesCallable; + private final OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable; + private final UnaryCallable + removeFulfillmentPlacesCallable; + private final OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable; + private final UnaryCallable addLocalInventoriesCallable; + private final OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable; + private final UnaryCallable + removeLocalInventoriesCallable; + private final OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductServiceStub create(ProductServiceStubSettings settings) + throws IOException { + return new HttpJsonProductServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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. + */ + protected HttpJsonProductServiceStub( + ProductServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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. + */ + protected HttpJsonProductServiceStub( + ProductServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.purgeProductsCallable = + callableFactory.createUnaryCallable( + purgeProductsTransportSettings, settings.purgeProductsSettings(), clientContext); + this.purgeProductsOperationCallable = + callableFactory.createOperationCallable( + purgeProductsTransportSettings, + settings.purgeProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importProductsCallable = + callableFactory.createUnaryCallable( + importProductsTransportSettings, settings.importProductsSettings(), clientContext); + this.importProductsOperationCallable = + callableFactory.createOperationCallable( + importProductsTransportSettings, + settings.importProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setInventoryCallable = + callableFactory.createUnaryCallable( + setInventoryTransportSettings, settings.setInventorySettings(), clientContext); + this.setInventoryOperationCallable = + callableFactory.createOperationCallable( + setInventoryTransportSettings, + settings.setInventoryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesSettings(), + clientContext); + this.addFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesSettings(), + clientContext); + this.removeFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addLocalInventoriesCallable = + callableFactory.createUnaryCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesSettings(), + clientContext); + this.addLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeLocalInventoriesCallable = + callableFactory.createUnaryCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesSettings(), + clientContext); + this.removeLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(purgeProductsMethodDescriptor); + methodDescriptors.add(importProductsMethodDescriptor); + methodDescriptors.add(setInventoryMethodDescriptor); + methodDescriptors.add(addFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(removeFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(addLocalInventoriesMethodDescriptor); + methodDescriptors.add(removeLocalInventoriesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable purgeProductsCallable() { + return purgeProductsCallable; + } + + @Override + public OperationCallable + purgeProductsOperationCallable() { + return purgeProductsOperationCallable; + } + + @Override + public UnaryCallable importProductsCallable() { + return importProductsCallable; + } + + @Override + public OperationCallable + importProductsOperationCallable() { + return importProductsOperationCallable; + } + + @Override + public UnaryCallable setInventoryCallable() { + return setInventoryCallable; + } + + @Override + public OperationCallable + setInventoryOperationCallable() { + return setInventoryOperationCallable; + } + + @Override + public UnaryCallable addFulfillmentPlacesCallable() { + return addFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable() { + return addFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable + removeFulfillmentPlacesCallable() { + return removeFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable() { + return removeFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable addLocalInventoriesCallable() { + return addLocalInventoriesCallable; + } + + @Override + public OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable() { + return addLocalInventoriesOperationCallable; + } + + @Override + public UnaryCallable removeLocalInventoriesCallable() { + return removeLocalInventoriesCallable; + } + + @Override + public OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable() { + return removeLocalInventoriesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceCallableFactory.java new file mode 100644 index 000000000000..39aa67d705f6 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SearchService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceStub.java new file mode 100644 index 000000000000..03335485b09b --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonSearchServiceStub.java @@ -0,0 +1,204 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.SearchServiceClient.SearchPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SearchService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceStub extends SearchServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor searchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.SearchService/Search") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable searchCallable; + private final UnaryCallable searchPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSearchServiceStub create(SearchServiceStubSettings settings) + throws IOException { + return new HttpJsonSearchServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSearchServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSearchServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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. + */ + protected HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSearchServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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. + */ + protected HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings searchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.searchCallable = + callableFactory.createUnaryCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + this.searchPagedCallable = + callableFactory.createPagedCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(searchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable searchCallable() { + return searchCallable; + } + + @Override + public UnaryCallable searchPagedCallable() { + return searchPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceCallableFactory.java new file mode 100644 index 000000000000..b440ec40b92a --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ServingConfigService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceStub.java new file mode 100644 index 000000000000..17883438a2bb --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonServingConfigServiceStub.java @@ -0,0 +1,544 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import static com.google.cloud.retail.v2alpha.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.AddControlRequest; +import com.google.cloud.retail.v2alpha.CreateServingConfigRequest; +import com.google.cloud.retail.v2alpha.DeleteServingConfigRequest; +import com.google.cloud.retail.v2alpha.GetServingConfigRequest; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ListServingConfigsResponse; +import com.google.cloud.retail.v2alpha.RemoveControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.UpdateServingConfigRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ServingConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceStub extends ServingConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/CreateServingConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "servingConfigId", request.getServingConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/DeleteServingConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/UpdateServingConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{servingConfig.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig.name", request.getServingConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/GetServingConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listServingConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2alpha.ServingConfigService/ListServingConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListServingConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ServingConfigService/AddControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.ServingConfigService/RemoveControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createServingConfigCallable; + private final UnaryCallable deleteServingConfigCallable; + private final UnaryCallable + updateServingConfigCallable; + private final UnaryCallable getServingConfigCallable; + private final UnaryCallable + listServingConfigsCallable; + private final UnaryCallable + listServingConfigsPagedCallable; + private final UnaryCallable addControlCallable; + private final UnaryCallable removeControlCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonServingConfigServiceStub create( + ServingConfigServiceStubSettings settings) throws IOException { + return new HttpJsonServingConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonServingConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonServingConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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. + */ + protected HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonServingConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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. + */ + protected HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + createServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listServingConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listServingConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings addControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings removeControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createServingConfigCallable = + callableFactory.createUnaryCallable( + createServingConfigTransportSettings, + settings.createServingConfigSettings(), + clientContext); + this.deleteServingConfigCallable = + callableFactory.createUnaryCallable( + deleteServingConfigTransportSettings, + settings.deleteServingConfigSettings(), + clientContext); + this.updateServingConfigCallable = + callableFactory.createUnaryCallable( + updateServingConfigTransportSettings, + settings.updateServingConfigSettings(), + clientContext); + this.getServingConfigCallable = + callableFactory.createUnaryCallable( + getServingConfigTransportSettings, settings.getServingConfigSettings(), clientContext); + this.listServingConfigsCallable = + callableFactory.createUnaryCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.listServingConfigsPagedCallable = + callableFactory.createPagedCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.addControlCallable = + callableFactory.createUnaryCallable( + addControlTransportSettings, settings.addControlSettings(), clientContext); + this.removeControlCallable = + callableFactory.createUnaryCallable( + removeControlTransportSettings, settings.removeControlSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createServingConfigMethodDescriptor); + methodDescriptors.add(deleteServingConfigMethodDescriptor); + methodDescriptors.add(updateServingConfigMethodDescriptor); + methodDescriptors.add(getServingConfigMethodDescriptor); + methodDescriptors.add(listServingConfigsMethodDescriptor); + methodDescriptors.add(addControlMethodDescriptor); + methodDescriptors.add(removeControlMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createServingConfigCallable() { + return createServingConfigCallable; + } + + @Override + public UnaryCallable deleteServingConfigCallable() { + return deleteServingConfigCallable; + } + + @Override + public UnaryCallable updateServingConfigCallable() { + return updateServingConfigCallable; + } + + @Override + public UnaryCallable getServingConfigCallable() { + return getServingConfigCallable; + } + + @Override + public UnaryCallable + listServingConfigsCallable() { + return listServingConfigsCallable; + } + + @Override + public UnaryCallable + listServingConfigsPagedCallable() { + return listServingConfigsPagedCallable; + } + + @Override + public UnaryCallable addControlCallable() { + return addControlCallable; + } + + @Override + public UnaryCallable removeControlCallable() { + return removeControlCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceCallableFactory.java new file mode 100644 index 000000000000..149417cdc56e --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the UserEventService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceStub.java new file mode 100644 index 000000000000..df1eb7054bf6 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/HttpJsonUserEventServiceStub.java @@ -0,0 +1,481 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub; + +import com.google.api.HttpBody; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2alpha.CollectUserEventRequest; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.ImportUserEventsResponse; +import com.google.cloud.retail.v2alpha.PurgeMetadata; +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.PurgeUserEventsResponse; +import com.google.cloud.retail.v2alpha.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.RejoinUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.cloud.retail.v2alpha.WriteUserEventRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the UserEventService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceStub extends UserEventServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RejoinUserEventsResponse.getDescriptor()) + .add(PurgeUserEventsResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(ImportUserEventsResponse.getDescriptor()) + .add(RejoinUserEventsMetadata.getDescriptor()) + .add(PurgeMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + writeUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/WriteUserEvent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("userEvent", request.getUserEvent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserEvent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + collectUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/CollectUserEvent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "ets", request.getEts()); + serializer.putQueryParam(fields, "uri", request.getUri()); + serializer.putQueryParam(fields, "userEvent", request.getUserEvent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HttpBody.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + purgeUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/PurgeUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (PurgeUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/ImportUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rejoinUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2alpha.UserEventService/RejoinUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RejoinUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable writeUserEventCallable; + private final UnaryCallable collectUserEventCallable; + private final UnaryCallable purgeUserEventsCallable; + private final OperationCallable + purgeUserEventsOperationCallable; + private final UnaryCallable importUserEventsCallable; + private final OperationCallable + importUserEventsOperationCallable; + private final UnaryCallable rejoinUserEventsCallable; + private final OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonUserEventServiceStub create(UserEventServiceStubSettings settings) + throws IOException { + return new HttpJsonUserEventServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonUserEventServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonUserEventServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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. + */ + protected HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonUserEventServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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. + */ + protected HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings writeUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(writeUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings collectUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(collectUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings rejoinUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rejoinUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.writeUserEventCallable = + callableFactory.createUnaryCallable( + writeUserEventTransportSettings, settings.writeUserEventSettings(), clientContext); + this.collectUserEventCallable = + callableFactory.createUnaryCallable( + collectUserEventTransportSettings, settings.collectUserEventSettings(), clientContext); + this.purgeUserEventsCallable = + callableFactory.createUnaryCallable( + purgeUserEventsTransportSettings, settings.purgeUserEventsSettings(), clientContext); + this.purgeUserEventsOperationCallable = + callableFactory.createOperationCallable( + purgeUserEventsTransportSettings, + settings.purgeUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importUserEventsCallable = + callableFactory.createUnaryCallable( + importUserEventsTransportSettings, settings.importUserEventsSettings(), clientContext); + this.importUserEventsOperationCallable = + callableFactory.createOperationCallable( + importUserEventsTransportSettings, + settings.importUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rejoinUserEventsCallable = + callableFactory.createUnaryCallable( + rejoinUserEventsTransportSettings, settings.rejoinUserEventsSettings(), clientContext); + this.rejoinUserEventsOperationCallable = + callableFactory.createOperationCallable( + rejoinUserEventsTransportSettings, + settings.rejoinUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(writeUserEventMethodDescriptor); + methodDescriptors.add(collectUserEventMethodDescriptor); + methodDescriptors.add(purgeUserEventsMethodDescriptor); + methodDescriptors.add(importUserEventsMethodDescriptor); + methodDescriptors.add(rejoinUserEventsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable writeUserEventCallable() { + return writeUserEventCallable; + } + + @Override + public UnaryCallable collectUserEventCallable() { + return collectUserEventCallable; + } + + @Override + public UnaryCallable purgeUserEventsCallable() { + return purgeUserEventsCallable; + } + + @Override + public OperationCallable + purgeUserEventsOperationCallable() { + return purgeUserEventsOperationCallable; + } + + @Override + public UnaryCallable importUserEventsCallable() { + return importUserEventsCallable; + } + + @Override + public OperationCallable + importUserEventsOperationCallable() { + return importUserEventsOperationCallable; + } + + @Override + public UnaryCallable rejoinUserEventsCallable() { + return rejoinUserEventsCallable; + } + + @Override + public OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable() { + return rejoinUserEventsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.java index edc0d9e15f25..4cb6f0fd57ac 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/PredictionServiceStubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -97,6 +100,11 @@ public PredictionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPredictionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPredictionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -129,18 +137,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(PredictionServiceStubSettings.class)) @@ -148,11 +163,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(PredictionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PredictionServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -242,6 +276,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .predictSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java index 5f5f0e8ffe91..a3f6076d2a44 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStub.java @@ -66,7 +66,11 @@ public abstract class ProductServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable createProductCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java index c8b64468c631..2e0844927b26 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ProductServiceStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -339,6 +342,11 @@ public ProductServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -371,18 +379,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ProductServiceStubSettings.class)) @@ -390,11 +405,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ProductServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -629,6 +663,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createProductSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java index 8d50bddffa43..f75f284efaa1 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/SearchServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -158,6 +161,11 @@ public SearchServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSearchServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSearchServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -190,18 +198,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SearchServiceStubSettings.class)) @@ -209,11 +224,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SearchServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SearchServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -304,6 +338,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .searchSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java index 78dd0b11ae7a..a1fd03f7b9bb 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/ServingConfigServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -219,6 +222,11 @@ public ServingConfigServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServingConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonServingConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -251,18 +259,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ServingConfigServiceStubSettings.class)) @@ -270,11 +285,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ServingConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ServingConfigServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -397,6 +431,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createServingConfigSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java index ff7156131ae2..ffa15cbf1643 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStub.java @@ -48,7 +48,11 @@ public abstract class UserEventServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable writeUserEventCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java index 70384ba393f5..33f425bf4e5c 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2alpha/stub/UserEventServiceStubSettings.java @@ -26,6 +26,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -164,6 +167,11 @@ public UserEventServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcUserEventServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonUserEventServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -196,18 +204,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(UserEventServiceStubSettings.class)) @@ -215,11 +230,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(UserEventServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return UserEventServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -390,6 +424,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .writeUserEventSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java index 32a3f1b70229..c9e39df81b24 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceClient.java @@ -100,6 +100,20 @@ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * CatalogServiceSettings catalogServiceSettings =
+ *     CatalogServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java index 071fbcd0ea40..09c6f2b2e2a9 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CatalogServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -162,11 +163,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CatalogServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return CatalogServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CatalogServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CatalogServiceStubSettings.defaultTransportChannelProvider(); } @@ -176,11 +184,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CatalogServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -218,6 +232,11 @@ private static Builder createDefault() { return new Builder(CatalogServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CatalogServiceStubSettings.newHttpJsonBuilder()); + } + public CatalogServiceStubSettings.Builder getStubSettingsBuilder() { return ((CatalogServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.java index cb4be1ee51aa..2f7eb20b56eb 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.retail.v2beta.stub.CompletionServiceStub; import com.google.cloud.retail.v2beta.stub.CompletionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -108,6 +108,21 @@ * CompletionServiceClient.create(completionServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * CompletionServiceSettings completionServiceSettings =
+ *     CompletionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CompletionServiceClient completionServiceClient =
+ *     CompletionServiceClient.create(completionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -115,7 +130,8 @@ public class CompletionServiceClient implements BackgroundResource { private final CompletionServiceSettings settings; private final CompletionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CompletionServiceClient with default settings. */ public static final CompletionServiceClient create() throws IOException { @@ -147,13 +163,17 @@ public static final CompletionServiceClient create(CompletionServiceStub stub) { protected CompletionServiceClient(CompletionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((CompletionServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected CompletionServiceClient(CompletionServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final CompletionServiceSettings getSettings() { @@ -168,10 +188,18 @@ public CompletionServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Completes the specified prefix with keyword suggestions. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.java index c6d4c94ab19c..8d7abe19dff9 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/CompletionServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -114,11 +115,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CompletionServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return CompletionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CompletionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CompletionServiceStubSettings.defaultTransportChannelProvider(); } @@ -128,11 +136,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CompletionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -170,6 +184,11 @@ private static Builder createDefault() { return new Builder(CompletionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CompletionServiceStubSettings.newHttpJsonBuilder()); + } + public CompletionServiceStubSettings.Builder getStubSettingsBuilder() { return ((CompletionServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java index 6de06b99f3a1..f4639666da40 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceClient.java @@ -101,6 +101,20 @@ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ControlServiceSettings controlServiceSettings =
+ *     ControlServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java index bf76392db671..dad65f88aa81 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ControlServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -124,11 +125,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ControlServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ControlServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ControlServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ControlServiceStubSettings.defaultTransportChannelProvider(); } @@ -138,11 +146,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ControlServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -180,6 +194,11 @@ private static Builder createDefault() { return new Builder(ControlServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ControlServiceStubSettings.newHttpJsonBuilder()); + } + public ControlServiceStubSettings.Builder getStubSettingsBuilder() { return ((ControlServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java index 6819b8ca8886..d7f3b524211b 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceClient.java @@ -102,6 +102,21 @@ * PredictionServiceClient.create(predictionServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PredictionServiceSettings predictionServiceSettings =
+ *     PredictionServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * PredictionServiceClient predictionServiceClient =
+ *     PredictionServiceClient.create(predictionServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.java index f822c478ad55..540b33d96756 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/PredictionServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -99,11 +100,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PredictionServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PredictionServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PredictionServiceStubSettings.defaultTransportChannelProvider(); } @@ -113,11 +121,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PredictionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -155,6 +169,11 @@ private static Builder createDefault() { return new Builder(PredictionServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PredictionServiceStubSettings.newHttpJsonBuilder()); + } + public PredictionServiceStubSettings.Builder getStubSettingsBuilder() { return ((PredictionServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.java index 57c536d2c2ff..137157faa3c4 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.retail.v2beta.stub.ProductServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -106,6 +106,20 @@ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ProductServiceSettings productServiceSettings =
+ *     ProductServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -113,7 +127,8 @@ public class ProductServiceClient implements BackgroundResource { private final ProductServiceSettings settings; private final ProductServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProductServiceClient with default settings. */ public static final ProductServiceClient create() throws IOException { @@ -145,13 +160,17 @@ public static final ProductServiceClient create(ProductServiceStub stub) { protected ProductServiceClient(ProductServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ProductServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ProductServiceClient(ProductServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ProductServiceSettings getSettings() { @@ -166,10 +185,18 @@ public ProductServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a [Product][google.cloud.retail.v2beta.Product]. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java index fb3b0c1772d7..0beba68db8f9 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ProductServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -204,11 +205,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProductServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ProductServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProductServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProductServiceStubSettings.defaultTransportChannelProvider(); } @@ -218,11 +226,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProductServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -260,6 +274,11 @@ private static Builder createDefault() { return new Builder(ProductServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProductServiceStubSettings.newHttpJsonBuilder()); + } + public ProductServiceStubSettings.Builder getStubSettingsBuilder() { return ((ProductServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java index 49c69616c6c8..c2c045a2843e 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceClient.java @@ -123,6 +123,20 @@ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SearchServiceSettings searchServiceSettings =
+ *     SearchServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java index 2546b5a74ef4..408f51bec156 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/SearchServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -101,11 +102,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SearchServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SearchServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SearchServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SearchServiceStubSettings.defaultTransportChannelProvider(); } @@ -115,11 +123,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SearchServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -157,6 +171,11 @@ private static Builder createDefault() { return new Builder(SearchServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SearchServiceStubSettings.newHttpJsonBuilder()); + } + public SearchServiceStubSettings.Builder getStubSettingsBuilder() { return ((SearchServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java index 17c513cd559e..393fbcc88da6 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceClient.java @@ -106,6 +106,21 @@ * ServingConfigServiceClient.create(servingConfigServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ServingConfigServiceSettings servingConfigServiceSettings =
+ *     ServingConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ServingConfigServiceClient servingConfigServiceClient =
+ *     ServingConfigServiceClient.create(servingConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java index 60d568632d92..641d2d3ffac7 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/ServingConfigServiceSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -138,11 +139,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ServingConfigServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ServingConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ServingConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ServingConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -152,11 +160,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ServingConfigServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -195,6 +209,11 @@ private static Builder createDefault() { return new Builder(ServingConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ServingConfigServiceStubSettings.newHttpJsonBuilder()); + } + public ServingConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((ServingConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java index 7ee1b39c22bf..8454f02b8aeb 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceClient.java @@ -19,13 +19,13 @@ import com.google.api.HttpBody; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.retail.v2beta.stub.UserEventServiceStub; import com.google.cloud.retail.v2beta.stub.UserEventServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -101,6 +101,21 @@ * UserEventServiceClient.create(userEventServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * UserEventServiceSettings userEventServiceSettings =
+ *     UserEventServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * UserEventServiceClient userEventServiceClient =
+ *     UserEventServiceClient.create(userEventServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -108,7 +123,8 @@ public class UserEventServiceClient implements BackgroundResource { private final UserEventServiceSettings settings; private final UserEventServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of UserEventServiceClient with default settings. */ public static final UserEventServiceClient create() throws IOException { @@ -140,13 +156,17 @@ public static final UserEventServiceClient create(UserEventServiceStub stub) { protected UserEventServiceClient(UserEventServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((UserEventServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected UserEventServiceClient(UserEventServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final UserEventServiceSettings getSettings() { @@ -161,10 +181,18 @@ public UserEventServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Writes a single user event. diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java index 68ae15b2c70f..527b38cf439f 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/UserEventServiceSettings.java @@ -22,6 +22,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -141,11 +142,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return UserEventServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return UserEventServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return UserEventServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return UserEventServiceStubSettings.defaultTransportChannelProvider(); } @@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return UserEventServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -197,6 +211,11 @@ private static Builder createDefault() { return new Builder(UserEventServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(UserEventServiceStubSettings.newHttpJsonBuilder()); + } + public UserEventServiceStubSettings.Builder getStubSettingsBuilder() { return ((UserEventServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java index eb8c5830616f..ea6b765d5acf 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CatalogServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -252,6 +255,11 @@ public CatalogServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCatalogServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCatalogServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -284,18 +292,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) @@ -303,11 +318,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CatalogServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -470,6 +504,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listCatalogsSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java index 055478f2f9ea..76673725adde 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStub.java @@ -40,7 +40,11 @@ public abstract class CompletionServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable completeQueryCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.java index 4fe5cbbce315..db28316a2d68 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/CompletionServiceStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -123,6 +126,11 @@ public CompletionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCompletionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCompletionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -155,18 +163,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(CompletionServiceStubSettings.class)) @@ -174,11 +189,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(CompletionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CompletionServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -284,6 +318,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .completeQuerySettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java index 8014e8b78fce..70f48e46b8fe 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ControlServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -190,6 +193,11 @@ public ControlServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcControlServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonControlServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -222,18 +230,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ControlServiceStubSettings.class)) @@ -241,11 +256,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ControlServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ControlServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -350,6 +384,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createControlSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceCallableFactory.java new file mode 100644 index 000000000000..02be2d9d0461 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the CatalogService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceStub.java new file mode 100644 index 000000000000..f1021c22a3e2 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCatalogServiceStub.java @@ -0,0 +1,769 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.CatalogServiceClient.ListCatalogsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.GetAttributesConfigRequest; +import com.google.cloud.retail.v2beta.GetCompletionConfigRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.ListCatalogsResponse; +import com.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.SetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.UpdateAttributesConfigRequest; +import com.google.cloud.retail.v2beta.UpdateCatalogRequest; +import com.google.cloud.retail.v2beta.UpdateCompletionConfigRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the CatalogService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCatalogServiceStub extends CatalogServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listCatalogsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/ListCatalogs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*}/catalogs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCatalogsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCatalogMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateCatalog") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "catalog.name", request.getCatalog().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("catalog", request.getCatalog())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Catalog.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/SetDefaultBranch") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearCatalog().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDefaultBranchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetDefaultBranch") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GetDefaultBranchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetCompletionConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateCompletionConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateCompletionConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{completionConfig.name=projects/*/locations/*/catalogs/*/completionConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "completionConfig.name", + request.getCompletionConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("completionConfig", request.getCompletionConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompletionConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetAttributesConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateAttributesConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateAttributesConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig.name=projects/*/locations/*/catalogs/*/attributesConfig}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "attributesConfig.name", + request.getAttributesConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("attributesConfig", request.getAttributesConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/AddCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CatalogService/RemoveCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + replaceCatalogAttributeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.CatalogService/ReplaceCatalogAttribute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "attributesConfig", request.getAttributesConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearAttributesConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AttributesConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listCatalogsCallable; + private final UnaryCallable + listCatalogsPagedCallable; + private final UnaryCallable updateCatalogCallable; + private final UnaryCallable setDefaultBranchCallable; + private final UnaryCallable + getDefaultBranchCallable; + private final UnaryCallable + getCompletionConfigCallable; + private final UnaryCallable + updateCompletionConfigCallable; + private final UnaryCallable + getAttributesConfigCallable; + private final UnaryCallable + updateAttributesConfigCallable; + private final UnaryCallable + addCatalogAttributeCallable; + private final UnaryCallable + removeCatalogAttributeCallable; + private final UnaryCallable + replaceCatalogAttributeCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCatalogServiceStub create(CatalogServiceStubSettings settings) + throws IOException { + return new HttpJsonCatalogServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCatalogServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCatalogServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCatalogServiceStub( + CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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. + */ + protected HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCatalogServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCatalogServiceStub, 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. + */ + protected HttpJsonCatalogServiceStub( + CatalogServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listCatalogsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCatalogsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateCatalogTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCatalogMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDefaultBranchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDefaultBranchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateCompletionConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateCompletionConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateAttributesConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateAttributesConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + replaceCatalogAttributeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(replaceCatalogAttributeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listCatalogsCallable = + callableFactory.createUnaryCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.listCatalogsPagedCallable = + callableFactory.createPagedCallable( + listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); + this.updateCatalogCallable = + callableFactory.createUnaryCallable( + updateCatalogTransportSettings, settings.updateCatalogSettings(), clientContext); + this.setDefaultBranchCallable = + callableFactory.createUnaryCallable( + setDefaultBranchTransportSettings, settings.setDefaultBranchSettings(), clientContext); + this.getDefaultBranchCallable = + callableFactory.createUnaryCallable( + getDefaultBranchTransportSettings, settings.getDefaultBranchSettings(), clientContext); + this.getCompletionConfigCallable = + callableFactory.createUnaryCallable( + getCompletionConfigTransportSettings, + settings.getCompletionConfigSettings(), + clientContext); + this.updateCompletionConfigCallable = + callableFactory.createUnaryCallable( + updateCompletionConfigTransportSettings, + settings.updateCompletionConfigSettings(), + clientContext); + this.getAttributesConfigCallable = + callableFactory.createUnaryCallable( + getAttributesConfigTransportSettings, + settings.getAttributesConfigSettings(), + clientContext); + this.updateAttributesConfigCallable = + callableFactory.createUnaryCallable( + updateAttributesConfigTransportSettings, + settings.updateAttributesConfigSettings(), + clientContext); + this.addCatalogAttributeCallable = + callableFactory.createUnaryCallable( + addCatalogAttributeTransportSettings, + settings.addCatalogAttributeSettings(), + clientContext); + this.removeCatalogAttributeCallable = + callableFactory.createUnaryCallable( + removeCatalogAttributeTransportSettings, + settings.removeCatalogAttributeSettings(), + clientContext); + this.replaceCatalogAttributeCallable = + callableFactory.createUnaryCallable( + replaceCatalogAttributeTransportSettings, + settings.replaceCatalogAttributeSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listCatalogsMethodDescriptor); + methodDescriptors.add(updateCatalogMethodDescriptor); + methodDescriptors.add(setDefaultBranchMethodDescriptor); + methodDescriptors.add(getDefaultBranchMethodDescriptor); + methodDescriptors.add(getCompletionConfigMethodDescriptor); + methodDescriptors.add(updateCompletionConfigMethodDescriptor); + methodDescriptors.add(getAttributesConfigMethodDescriptor); + methodDescriptors.add(updateAttributesConfigMethodDescriptor); + methodDescriptors.add(addCatalogAttributeMethodDescriptor); + methodDescriptors.add(removeCatalogAttributeMethodDescriptor); + methodDescriptors.add(replaceCatalogAttributeMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listCatalogsCallable() { + return listCatalogsCallable; + } + + @Override + public UnaryCallable listCatalogsPagedCallable() { + return listCatalogsPagedCallable; + } + + @Override + public UnaryCallable updateCatalogCallable() { + return updateCatalogCallable; + } + + @Override + public UnaryCallable setDefaultBranchCallable() { + return setDefaultBranchCallable; + } + + @Override + public UnaryCallable + getDefaultBranchCallable() { + return getDefaultBranchCallable; + } + + @Override + public UnaryCallable getCompletionConfigCallable() { + return getCompletionConfigCallable; + } + + @Override + public UnaryCallable + updateCompletionConfigCallable() { + return updateCompletionConfigCallable; + } + + @Override + public UnaryCallable getAttributesConfigCallable() { + return getAttributesConfigCallable; + } + + @Override + public UnaryCallable + updateAttributesConfigCallable() { + return updateAttributesConfigCallable; + } + + @Override + public UnaryCallable addCatalogAttributeCallable() { + return addCatalogAttributeCallable; + } + + @Override + public UnaryCallable + removeCatalogAttributeCallable() { + return removeCatalogAttributeCallable; + } + + @Override + public UnaryCallable + replaceCatalogAttributeCallable() { + return replaceCatalogAttributeCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceCallableFactory.java new file mode 100644 index 000000000000..b60b3b26183e --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the CompletionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceStub.java new file mode 100644 index 000000000000..7fe1921c735b --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonCompletionServiceStub.java @@ -0,0 +1,292 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.CompleteQueryRequest; +import com.google.cloud.retail.v2beta.CompleteQueryResponse; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.cloud.retail.v2beta.ImportCompletionDataResponse; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the CompletionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCompletionServiceStub extends CompletionServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportMetadata.getDescriptor()) + .add(ImportCompletionDataResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + completeQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.CompletionService/CompleteQuery") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "catalog", request.getCatalog()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "dataset", request.getDataset()); + serializer.putQueryParam(fields, "deviceType", request.getDeviceType()); + serializer.putQueryParam( + fields, "languageCodes", request.getLanguageCodesList()); + serializer.putQueryParam( + fields, "maxSuggestions", request.getMaxSuggestions()); + serializer.putQueryParam(fields, "query", request.getQuery()); + serializer.putQueryParam(fields, "visitorId", request.getVisitorId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompleteQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importCompletionDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.CompletionService/ImportCompletionData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportCompletionDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable completeQueryCallable; + private final UnaryCallable importCompletionDataCallable; + private final OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCompletionServiceStub create(CompletionServiceStubSettings settings) + throws IOException { + return new HttpJsonCompletionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCompletionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCompletionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCompletionServiceStub( + CompletionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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. + */ + protected HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCompletionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCompletionServiceStub, 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. + */ + protected HttpJsonCompletionServiceStub( + CompletionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + completeQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + importCompletionDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importCompletionDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.completeQueryCallable = + callableFactory.createUnaryCallable( + completeQueryTransportSettings, settings.completeQuerySettings(), clientContext); + this.importCompletionDataCallable = + callableFactory.createUnaryCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataSettings(), + clientContext); + this.importCompletionDataOperationCallable = + callableFactory.createOperationCallable( + importCompletionDataTransportSettings, + settings.importCompletionDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(completeQueryMethodDescriptor); + methodDescriptors.add(importCompletionDataMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable completeQueryCallable() { + return completeQueryCallable; + } + + @Override + public UnaryCallable importCompletionDataCallable() { + return importCompletionDataCallable; + } + + @Override + public OperationCallable< + ImportCompletionDataRequest, ImportCompletionDataResponse, ImportMetadata> + importCompletionDataOperationCallable() { + return importCompletionDataOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceCallableFactory.java new file mode 100644 index 000000000000..596a6db17bda --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ControlService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceStub.java new file mode 100644 index 000000000000..cb2b790c5903 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonControlServiceStub.java @@ -0,0 +1,410 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.ControlServiceClient.ListControlsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.CreateControlRequest; +import com.google.cloud.retail.v2beta.DeleteControlRequest; +import com.google.cloud.retail.v2beta.GetControlRequest; +import com.google.cloud.retail.v2beta.ListControlsRequest; +import com.google.cloud.retail.v2beta.ListControlsResponse; +import com.google.cloud.retail.v2beta.UpdateControlRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ControlService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonControlServiceStub extends ControlServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/CreateControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "controlId", request.getControlId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/DeleteControl") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/UpdateControl") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "control.name", request.getControl().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("control", request.getControl())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/GetControl") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Control.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listControlsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ControlService/ListControls") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListControlsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createControlCallable; + private final UnaryCallable deleteControlCallable; + private final UnaryCallable updateControlCallable; + private final UnaryCallable getControlCallable; + private final UnaryCallable listControlsCallable; + private final UnaryCallable + listControlsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonControlServiceStub create(ControlServiceStubSettings settings) + throws IOException { + return new HttpJsonControlServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonControlServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonControlServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonControlServiceStub( + ControlServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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. + */ + protected HttpJsonControlServiceStub( + ControlServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonControlServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonControlServiceStub, 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. + */ + protected HttpJsonControlServiceStub( + ControlServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listControlsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listControlsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createControlCallable = + callableFactory.createUnaryCallable( + createControlTransportSettings, settings.createControlSettings(), clientContext); + this.deleteControlCallable = + callableFactory.createUnaryCallable( + deleteControlTransportSettings, settings.deleteControlSettings(), clientContext); + this.updateControlCallable = + callableFactory.createUnaryCallable( + updateControlTransportSettings, settings.updateControlSettings(), clientContext); + this.getControlCallable = + callableFactory.createUnaryCallable( + getControlTransportSettings, settings.getControlSettings(), clientContext); + this.listControlsCallable = + callableFactory.createUnaryCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + this.listControlsPagedCallable = + callableFactory.createPagedCallable( + listControlsTransportSettings, settings.listControlsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createControlMethodDescriptor); + methodDescriptors.add(deleteControlMethodDescriptor); + methodDescriptors.add(updateControlMethodDescriptor); + methodDescriptors.add(getControlMethodDescriptor); + methodDescriptors.add(listControlsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createControlCallable() { + return createControlCallable; + } + + @Override + public UnaryCallable deleteControlCallable() { + return deleteControlCallable; + } + + @Override + public UnaryCallable updateControlCallable() { + return updateControlCallable; + } + + @Override + public UnaryCallable getControlCallable() { + return getControlCallable; + } + + @Override + public UnaryCallable listControlsCallable() { + return listControlsCallable; + } + + @Override + public UnaryCallable listControlsPagedCallable() { + return listControlsPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 000000000000..040d5d1ca290 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the PredictionService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 000000000000..56364869c159 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,194 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.PredictRequest; +import com.google.cloud.retail.v2beta.PredictResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the PredictionService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPredictionServiceStub extends PredictionServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable predictCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPredictionServiceStub create(PredictionServiceStubSettings settings) + throws IOException { + return new HttpJsonPredictionServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPredictionServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPredictionServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPredictionServiceStub( + PredictionServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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. + */ + protected HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonPredictionServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPredictionServiceStub, 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. + */ + protected HttpJsonPredictionServiceStub( + PredictionServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceCallableFactory.java new file mode 100644 index 000000000000..e04094adb685 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ProductService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceStub.java new file mode 100644 index 000000000000..91057013e7f2 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonProductServiceStub.java @@ -0,0 +1,896 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.ProductServiceClient.ListProductsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.CreateProductRequest; +import com.google.cloud.retail.v2beta.DeleteProductRequest; +import com.google.cloud.retail.v2beta.GetProductRequest; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ImportProductsResponse; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.ListProductsResponse; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.SetInventoryMetadata; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.cloud.retail.v2beta.UpdateProductRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ProductService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonProductServiceStub extends ProductServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(RemoveLocalInventoriesResponse.getDescriptor()) + .add(ImportMetadata.getDescriptor()) + .add(AddFulfillmentPlacesMetadata.getDescriptor()) + .add(ImportProductsResponse.getDescriptor()) + .add(SetInventoryResponse.getDescriptor()) + .add(AddLocalInventoriesMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesMetadata.getDescriptor()) + .add(AddFulfillmentPlacesResponse.getDescriptor()) + .add(SetInventoryMetadata.getDescriptor()) + .add(RemoveFulfillmentPlacesResponse.getDescriptor()) + .add(AddLocalInventoriesResponse.getDescriptor()) + .add(RemoveLocalInventoriesMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/CreateProduct") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "productId", request.getProductId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/GetProduct") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/ListProducts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readMask", request.getReadMask()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProductsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/UpdateProduct") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "product.name", request.getProduct().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "allowMissing", request.getAllowMissing()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("product", request.getProduct())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Product.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteProductMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/DeleteProduct") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + importProductsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/ImportProducts") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportProductsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/SetInventory") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "inventory.name", request.getInventory().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (SetInventoryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/AddFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeFulfillmentPlacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ProductService/RemoveFulfillmentPlaces") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveFulfillmentPlacesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/AddLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AddLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeLocalInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ProductService/RemoveLocalInventories") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "product", request.getProduct()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearProduct().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RemoveLocalInventoriesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createProductCallable; + private final UnaryCallable getProductCallable; + private final UnaryCallable listProductsCallable; + private final UnaryCallable + listProductsPagedCallable; + private final UnaryCallable updateProductCallable; + private final UnaryCallable deleteProductCallable; + private final UnaryCallable importProductsCallable; + private final OperationCallable + importProductsOperationCallable; + private final UnaryCallable setInventoryCallable; + private final OperationCallable + setInventoryOperationCallable; + private final UnaryCallable addFulfillmentPlacesCallable; + private final OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable; + private final UnaryCallable + removeFulfillmentPlacesCallable; + private final OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable; + private final UnaryCallable addLocalInventoriesCallable; + private final OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable; + private final UnaryCallable + removeLocalInventoriesCallable; + private final OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProductServiceStub create(ProductServiceStubSettings settings) + throws IOException { + return new HttpJsonProductServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProductServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProductServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProductServiceStub( + ProductServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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. + */ + protected HttpJsonProductServiceStub( + ProductServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonProductServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProductServiceStub, 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. + */ + protected HttpJsonProductServiceStub( + ProductServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProductTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProductMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importProductsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importProductsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeFulfillmentPlacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeFulfillmentPlacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeLocalInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeLocalInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createProductCallable = + callableFactory.createUnaryCallable( + createProductTransportSettings, settings.createProductSettings(), clientContext); + this.getProductCallable = + callableFactory.createUnaryCallable( + getProductTransportSettings, settings.getProductSettings(), clientContext); + this.listProductsCallable = + callableFactory.createUnaryCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.listProductsPagedCallable = + callableFactory.createPagedCallable( + listProductsTransportSettings, settings.listProductsSettings(), clientContext); + this.updateProductCallable = + callableFactory.createUnaryCallable( + updateProductTransportSettings, settings.updateProductSettings(), clientContext); + this.deleteProductCallable = + callableFactory.createUnaryCallable( + deleteProductTransportSettings, settings.deleteProductSettings(), clientContext); + this.importProductsCallable = + callableFactory.createUnaryCallable( + importProductsTransportSettings, settings.importProductsSettings(), clientContext); + this.importProductsOperationCallable = + callableFactory.createOperationCallable( + importProductsTransportSettings, + settings.importProductsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setInventoryCallable = + callableFactory.createUnaryCallable( + setInventoryTransportSettings, settings.setInventorySettings(), clientContext); + this.setInventoryOperationCallable = + callableFactory.createOperationCallable( + setInventoryTransportSettings, + settings.setInventoryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesSettings(), + clientContext); + this.addFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + addFulfillmentPlacesTransportSettings, + settings.addFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeFulfillmentPlacesCallable = + callableFactory.createUnaryCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesSettings(), + clientContext); + this.removeFulfillmentPlacesOperationCallable = + callableFactory.createOperationCallable( + removeFulfillmentPlacesTransportSettings, + settings.removeFulfillmentPlacesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addLocalInventoriesCallable = + callableFactory.createUnaryCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesSettings(), + clientContext); + this.addLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + addLocalInventoriesTransportSettings, + settings.addLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeLocalInventoriesCallable = + callableFactory.createUnaryCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesSettings(), + clientContext); + this.removeLocalInventoriesOperationCallable = + callableFactory.createOperationCallable( + removeLocalInventoriesTransportSettings, + settings.removeLocalInventoriesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createProductMethodDescriptor); + methodDescriptors.add(getProductMethodDescriptor); + methodDescriptors.add(listProductsMethodDescriptor); + methodDescriptors.add(updateProductMethodDescriptor); + methodDescriptors.add(deleteProductMethodDescriptor); + methodDescriptors.add(importProductsMethodDescriptor); + methodDescriptors.add(setInventoryMethodDescriptor); + methodDescriptors.add(addFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(removeFulfillmentPlacesMethodDescriptor); + methodDescriptors.add(addLocalInventoriesMethodDescriptor); + methodDescriptors.add(removeLocalInventoriesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createProductCallable() { + return createProductCallable; + } + + @Override + public UnaryCallable getProductCallable() { + return getProductCallable; + } + + @Override + public UnaryCallable listProductsCallable() { + return listProductsCallable; + } + + @Override + public UnaryCallable listProductsPagedCallable() { + return listProductsPagedCallable; + } + + @Override + public UnaryCallable updateProductCallable() { + return updateProductCallable; + } + + @Override + public UnaryCallable deleteProductCallable() { + return deleteProductCallable; + } + + @Override + public UnaryCallable importProductsCallable() { + return importProductsCallable; + } + + @Override + public OperationCallable + importProductsOperationCallable() { + return importProductsOperationCallable; + } + + @Override + public UnaryCallable setInventoryCallable() { + return setInventoryCallable; + } + + @Override + public OperationCallable + setInventoryOperationCallable() { + return setInventoryOperationCallable; + } + + @Override + public UnaryCallable addFulfillmentPlacesCallable() { + return addFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + AddFulfillmentPlacesRequest, AddFulfillmentPlacesResponse, AddFulfillmentPlacesMetadata> + addFulfillmentPlacesOperationCallable() { + return addFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable + removeFulfillmentPlacesCallable() { + return removeFulfillmentPlacesCallable; + } + + @Override + public OperationCallable< + RemoveFulfillmentPlacesRequest, + RemoveFulfillmentPlacesResponse, + RemoveFulfillmentPlacesMetadata> + removeFulfillmentPlacesOperationCallable() { + return removeFulfillmentPlacesOperationCallable; + } + + @Override + public UnaryCallable addLocalInventoriesCallable() { + return addLocalInventoriesCallable; + } + + @Override + public OperationCallable< + AddLocalInventoriesRequest, AddLocalInventoriesResponse, AddLocalInventoriesMetadata> + addLocalInventoriesOperationCallable() { + return addLocalInventoriesOperationCallable; + } + + @Override + public UnaryCallable removeLocalInventoriesCallable() { + return removeLocalInventoriesCallable; + } + + @Override + public OperationCallable< + RemoveLocalInventoriesRequest, + RemoveLocalInventoriesResponse, + RemoveLocalInventoriesMetadata> + removeLocalInventoriesOperationCallable() { + return removeLocalInventoriesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceCallableFactory.java new file mode 100644 index 000000000000..68b6b4b9529c --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SearchService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceStub.java new file mode 100644 index 000000000000..01eb416d0ec7 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonSearchServiceStub.java @@ -0,0 +1,204 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.SearchServiceClient.SearchPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SearchService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSearchServiceStub extends SearchServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor searchMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.SearchService/Search") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "placement", request.getPlacement()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearPlacement().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable searchCallable; + private final UnaryCallable searchPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSearchServiceStub create(SearchServiceStubSettings settings) + throws IOException { + return new HttpJsonSearchServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSearchServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSearchServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSearchServiceStub( + SearchServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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. + */ + protected HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSearchServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSearchServiceStub, 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. + */ + protected HttpJsonSearchServiceStub( + SearchServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings searchTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.searchCallable = + callableFactory.createUnaryCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + this.searchPagedCallable = + callableFactory.createPagedCallable( + searchTransportSettings, settings.searchSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(searchMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable searchCallable() { + return searchCallable; + } + + @Override + public UnaryCallable searchPagedCallable() { + return searchPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceCallableFactory.java new file mode 100644 index 000000000000..fc8281bfc77f --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ServingConfigService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceStub.java new file mode 100644 index 000000000000..26f395569f1a --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonServingConfigServiceStub.java @@ -0,0 +1,543 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import static com.google.cloud.retail.v2beta.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.AddControlRequest; +import com.google.cloud.retail.v2beta.CreateServingConfigRequest; +import com.google.cloud.retail.v2beta.DeleteServingConfigRequest; +import com.google.cloud.retail.v2beta.GetServingConfigRequest; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ListServingConfigsResponse; +import com.google.cloud.retail.v2beta.RemoveControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.UpdateServingConfigRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ServingConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonServingConfigServiceStub extends ServingConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/CreateServingConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "servingConfigId", request.getServingConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/DeleteServingConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/UpdateServingConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{servingConfig.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig.name", request.getServingConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("servingConfig", request.getServingConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getServingConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ServingConfigService/GetServingConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listServingConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.retail.v2beta.ServingConfigService/ListServingConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListServingConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ServingConfigService/AddControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeControlMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.ServingConfigService/RemoveControl") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{servingConfig=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "servingConfig", request.getServingConfig()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServingConfig().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ServingConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createServingConfigCallable; + private final UnaryCallable deleteServingConfigCallable; + private final UnaryCallable + updateServingConfigCallable; + private final UnaryCallable getServingConfigCallable; + private final UnaryCallable + listServingConfigsCallable; + private final UnaryCallable + listServingConfigsPagedCallable; + private final UnaryCallable addControlCallable; + private final UnaryCallable removeControlCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonServingConfigServiceStub create( + ServingConfigServiceStubSettings settings) throws IOException { + return new HttpJsonServingConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonServingConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonServingConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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. + */ + protected HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonServingConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonServingConfigServiceStub, 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. + */ + protected HttpJsonServingConfigServiceStub( + ServingConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + createServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getServingConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getServingConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listServingConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listServingConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings addControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings removeControlTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeControlMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createServingConfigCallable = + callableFactory.createUnaryCallable( + createServingConfigTransportSettings, + settings.createServingConfigSettings(), + clientContext); + this.deleteServingConfigCallable = + callableFactory.createUnaryCallable( + deleteServingConfigTransportSettings, + settings.deleteServingConfigSettings(), + clientContext); + this.updateServingConfigCallable = + callableFactory.createUnaryCallable( + updateServingConfigTransportSettings, + settings.updateServingConfigSettings(), + clientContext); + this.getServingConfigCallable = + callableFactory.createUnaryCallable( + getServingConfigTransportSettings, settings.getServingConfigSettings(), clientContext); + this.listServingConfigsCallable = + callableFactory.createUnaryCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.listServingConfigsPagedCallable = + callableFactory.createPagedCallable( + listServingConfigsTransportSettings, + settings.listServingConfigsSettings(), + clientContext); + this.addControlCallable = + callableFactory.createUnaryCallable( + addControlTransportSettings, settings.addControlSettings(), clientContext); + this.removeControlCallable = + callableFactory.createUnaryCallable( + removeControlTransportSettings, settings.removeControlSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createServingConfigMethodDescriptor); + methodDescriptors.add(deleteServingConfigMethodDescriptor); + methodDescriptors.add(updateServingConfigMethodDescriptor); + methodDescriptors.add(getServingConfigMethodDescriptor); + methodDescriptors.add(listServingConfigsMethodDescriptor); + methodDescriptors.add(addControlMethodDescriptor); + methodDescriptors.add(removeControlMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createServingConfigCallable() { + return createServingConfigCallable; + } + + @Override + public UnaryCallable deleteServingConfigCallable() { + return deleteServingConfigCallable; + } + + @Override + public UnaryCallable updateServingConfigCallable() { + return updateServingConfigCallable; + } + + @Override + public UnaryCallable getServingConfigCallable() { + return getServingConfigCallable; + } + + @Override + public UnaryCallable + listServingConfigsCallable() { + return listServingConfigsCallable; + } + + @Override + public UnaryCallable + listServingConfigsPagedCallable() { + return listServingConfigsPagedCallable; + } + + @Override + public UnaryCallable addControlCallable() { + return addControlCallable; + } + + @Override + public UnaryCallable removeControlCallable() { + return removeControlCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceCallableFactory.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceCallableFactory.java new file mode 100644 index 000000000000..8b4856cfeec7 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the UserEventService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceStub.java new file mode 100644 index 000000000000..743bdbd1a851 --- /dev/null +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/HttpJsonUserEventServiceStub.java @@ -0,0 +1,481 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub; + +import com.google.api.HttpBody; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.retail.v2beta.CollectUserEventRequest; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.ImportUserEventsResponse; +import com.google.cloud.retail.v2beta.PurgeMetadata; +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.PurgeUserEventsResponse; +import com.google.cloud.retail.v2beta.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.RejoinUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.cloud.retail.v2beta.WriteUserEventRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the UserEventService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonUserEventServiceStub extends UserEventServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportMetadata.getDescriptor()) + .add(PurgeMetadata.getDescriptor()) + .add(ImportUserEventsResponse.getDescriptor()) + .add(RejoinUserEventsMetadata.getDescriptor()) + .add(RejoinUserEventsResponse.getDescriptor()) + .add(PurgeUserEventsResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + writeUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/WriteUserEvent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("userEvent", request.getUserEvent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserEvent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + collectUserEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/CollectUserEvent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "ets", request.getEts()); + serializer.putQueryParam(fields, "uri", request.getUri()); + serializer.putQueryParam(fields, "userEvent", request.getUserEvent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(HttpBody.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + purgeUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/PurgeUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (PurgeUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/ImportUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rejoinUserEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.retail.v2beta.UserEventService/RejoinUserEvents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RejoinUserEventsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable writeUserEventCallable; + private final UnaryCallable collectUserEventCallable; + private final UnaryCallable purgeUserEventsCallable; + private final OperationCallable + purgeUserEventsOperationCallable; + private final UnaryCallable importUserEventsCallable; + private final OperationCallable + importUserEventsOperationCallable; + private final UnaryCallable rejoinUserEventsCallable; + private final OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonUserEventServiceStub create(UserEventServiceStubSettings settings) + throws IOException { + return new HttpJsonUserEventServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonUserEventServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonUserEventServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonUserEventServiceStub( + UserEventServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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. + */ + protected HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonUserEventServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonUserEventServiceStub, 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. + */ + protected HttpJsonUserEventServiceStub( + UserEventServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings writeUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(writeUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings collectUserEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(collectUserEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings purgeUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(purgeUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings rejoinUserEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rejoinUserEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.writeUserEventCallable = + callableFactory.createUnaryCallable( + writeUserEventTransportSettings, settings.writeUserEventSettings(), clientContext); + this.collectUserEventCallable = + callableFactory.createUnaryCallable( + collectUserEventTransportSettings, settings.collectUserEventSettings(), clientContext); + this.purgeUserEventsCallable = + callableFactory.createUnaryCallable( + purgeUserEventsTransportSettings, settings.purgeUserEventsSettings(), clientContext); + this.purgeUserEventsOperationCallable = + callableFactory.createOperationCallable( + purgeUserEventsTransportSettings, + settings.purgeUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importUserEventsCallable = + callableFactory.createUnaryCallable( + importUserEventsTransportSettings, settings.importUserEventsSettings(), clientContext); + this.importUserEventsOperationCallable = + callableFactory.createOperationCallable( + importUserEventsTransportSettings, + settings.importUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rejoinUserEventsCallable = + callableFactory.createUnaryCallable( + rejoinUserEventsTransportSettings, settings.rejoinUserEventsSettings(), clientContext); + this.rejoinUserEventsOperationCallable = + callableFactory.createOperationCallable( + rejoinUserEventsTransportSettings, + settings.rejoinUserEventsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(writeUserEventMethodDescriptor); + methodDescriptors.add(collectUserEventMethodDescriptor); + methodDescriptors.add(purgeUserEventsMethodDescriptor); + methodDescriptors.add(importUserEventsMethodDescriptor); + methodDescriptors.add(rejoinUserEventsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable writeUserEventCallable() { + return writeUserEventCallable; + } + + @Override + public UnaryCallable collectUserEventCallable() { + return collectUserEventCallable; + } + + @Override + public UnaryCallable purgeUserEventsCallable() { + return purgeUserEventsCallable; + } + + @Override + public OperationCallable + purgeUserEventsOperationCallable() { + return purgeUserEventsOperationCallable; + } + + @Override + public UnaryCallable importUserEventsCallable() { + return importUserEventsCallable; + } + + @Override + public OperationCallable + importUserEventsOperationCallable() { + return importUserEventsOperationCallable; + } + + @Override + public UnaryCallable rejoinUserEventsCallable() { + return rejoinUserEventsCallable; + } + + @Override + public OperationCallable< + RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> + rejoinUserEventsOperationCallable() { + return rejoinUserEventsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.java index 3af1061bfdee..241806ebe78d 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/PredictionServiceStubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -97,6 +100,11 @@ public PredictionServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPredictionServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPredictionServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -129,18 +137,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(PredictionServiceStubSettings.class)) @@ -148,11 +163,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(PredictionServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PredictionServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -242,6 +276,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .predictSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java index 52979a6a45f1..2d3264f24c4b 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStub.java @@ -63,7 +63,11 @@ public abstract class ProductServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable createProductCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java index 2a16e4e83cfc..502ecab772fb 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ProductServiceStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -321,6 +324,11 @@ public ProductServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProductServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProductServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -353,18 +361,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ProductServiceStubSettings.class)) @@ -372,11 +387,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ProductServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProductServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -599,6 +633,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createProductSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java index 5f1296a4a7c2..ac829cbe989e 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/SearchServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -158,6 +161,11 @@ public SearchServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSearchServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSearchServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -190,18 +198,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SearchServiceStubSettings.class)) @@ -209,11 +224,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SearchServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SearchServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -304,6 +338,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .searchSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java index 8b39f4b4f705..94504ec487ad 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/ServingConfigServiceStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -219,6 +222,11 @@ public ServingConfigServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServingConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonServingConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -251,18 +259,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ServingConfigServiceStubSettings.class)) @@ -270,11 +285,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ServingConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ServingConfigServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -397,6 +431,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createServingConfigSettings() diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java index d1661d09cef2..9b66435900e4 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStub.java @@ -48,7 +48,11 @@ public abstract class UserEventServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable writeUserEventCallable() { diff --git a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java index 7fb8a01ceb0c..94c823c46622 100644 --- a/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java +++ b/java-retail/google-cloud-retail/src/main/java/com/google/cloud/retail/v2beta/stub/UserEventServiceStubSettings.java @@ -26,6 +26,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -164,6 +167,11 @@ public UserEventServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcUserEventServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonUserEventServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -196,18 +204,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(UserEventServiceStubSettings.class)) @@ -215,11 +230,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(UserEventServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return UserEventServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -390,6 +424,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .writeUserEventSettings() diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CatalogServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CatalogServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..2dfe6eba3c6c --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CatalogServiceClientHttpJsonTest.java @@ -0,0 +1,410 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2; + +import static com.google.cloud.retail.v2.CatalogServiceClient.ListCatalogsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2.stub.HttpJsonCatalogServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CatalogServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CatalogServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCatalogServiceStub.getMethodDescriptors(), + CatalogServiceSettings.getDefaultEndpoint()); + CatalogServiceSettings settings = + CatalogServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CatalogServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listCatalogsTest() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCatalogsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCatalogsTest2() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCatalogsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCatalogTest() throws Exception { + Catalog expectedResponse = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Catalog actualResponse = client.updateCatalog(catalog, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateCatalogExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCatalog(catalog, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + client.setDefaultBranch(catalog); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + client.setDefaultBranch(catalog); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest2() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CompletionServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CompletionServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..b41da0f28e54 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/CompletionServiceClientHttpJsonTest.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2.stub.HttpJsonCompletionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CompletionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CompletionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCompletionServiceStub.getMethodDescriptors(), + CompletionServiceSettings.getDefaultEndpoint()); + CompletionServiceSettings settings = + CompletionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CompletionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void completeQueryTest() throws Exception { + CompleteQueryResponse expectedResponse = + CompleteQueryResponse.newBuilder() + .addAllCompletionResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllRecentSearchResults(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + + CompleteQueryResponse actualResponse = client.completeQuery(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void completeQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + client.completeQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importCompletionDataTest() throws Exception { + ImportCompletionDataResponse expectedResponse = + ImportCompletionDataResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importCompletionDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportCompletionDataResponse actualResponse = client.importCompletionDataAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importCompletionDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importCompletionDataAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/PredictionServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..35ec335a38e0 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,145 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2.stub.HttpJsonPredictionServiceStub; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class PredictionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static PredictionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPredictionServiceStub.getMethodDescriptors(), + PredictionServiceSettings.getDefaultEndpoint()); + PredictionServiceSettings settings = + PredictionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PredictionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void predictTest() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllMissingIds(new ArrayList()) + .setValidateOnly(true) + .build(); + mockService.addResponse(expectedResponse); + + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + PredictResponse actualResponse = client.predict(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void predictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.predict(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/ProductServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/ProductServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..d6d5296ce0f5 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/ProductServiceClientHttpJsonTest.java @@ -0,0 +1,1300 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2; + +import static com.google.cloud.retail.v2.ProductServiceClient.ListProductsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2.stub.HttpJsonProductServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ProductServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductServiceStub.getMethodDescriptors(), + ProductServiceSettings.getDefaultEndpoint()); + ProductServiceSettings settings = + ProductServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Product actualResponse = client.updateProduct(product, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProduct(product, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importProductsTest() throws Exception { + ImportProductsResponse expectedResponse = + ImportProductsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportProductsResponse actualResponse = client.importProductsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setInventoryTest() throws Exception { + SetInventoryResponse expectedResponse = SetInventoryResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setInventoryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + + SetInventoryResponse actualResponse = client.setInventoryAsync(inventory, setMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + client.setInventoryAsync(inventory, setMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest2() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest2() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest2() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest2() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/SearchServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/SearchServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..38e50c2103cd --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/SearchServiceClientHttpJsonTest.java @@ -0,0 +1,177 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2; + +import static com.google.cloud.retail.v2.SearchServiceClient.SearchPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2.stub.HttpJsonSearchServiceStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SearchServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static SearchServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSearchServiceStub.getMethodDescriptors(), + SearchServiceSettings.getDefaultEndpoint()); + SearchServiceSettings settings = + SearchServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SearchServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void searchTest() throws Exception { + SearchResponse.SearchResult responsesElement = SearchResponse.SearchResult.newBuilder().build(); + SearchResponse expectedResponse = + SearchResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + + SearchPagedResponse pagedListResponse = client.search(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + client.search(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/UserEventServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/UserEventServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..73544d3f6f10 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2/UserEventServiceClientHttpJsonTest.java @@ -0,0 +1,382 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2; + +import com.google.api.HttpBody; +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2.stub.HttpJsonUserEventServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class UserEventServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static UserEventServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonUserEventServiceStub.getMethodDescriptors(), + UserEventServiceSettings.getDefaultEndpoint()); + UserEventServiceSettings settings = + UserEventServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = UserEventServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void writeUserEventTest() throws Exception { + UserEvent expectedResponse = + UserEvent.newBuilder() + .setEventType("eventType31430900") + .setVisitorId("visitorId1880545833") + .setSessionId("sessionId607796817") + .setEventTime(Timestamp.newBuilder().build()) + .addAllExperimentIds(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllProductDetails(new ArrayList()) + .setCompletionDetail(CompletionDetail.newBuilder().build()) + .putAllAttributes(new HashMap()) + .setCartId("cartId-1367589797") + .setPurchaseTransaction(PurchaseTransaction.newBuilder().build()) + .setSearchQuery("searchQuery-552137728") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setOffset(-1019779949) + .addAllPageCategories(new ArrayList()) + .setUserInfo(UserInfo.newBuilder().build()) + .setUri("uri116076") + .setReferrerUri("referrerUri348088525") + .setPageViewId("pageViewId1362499087") + .build(); + mockService.addResponse(expectedResponse); + + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + + UserEvent actualResponse = client.writeUserEvent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void writeUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + client.writeUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void collectUserEventTest() throws Exception { + HttpBody expectedResponse = + HttpBody.newBuilder() + .setContentType("contentType-389131437") + .setData(ByteString.EMPTY) + .addAllExtensions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + + HttpBody actualResponse = client.collectUserEvent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void collectUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + client.collectUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeUserEventsTest() throws Exception { + PurgeUserEventsResponse expectedResponse = + PurgeUserEventsResponse.newBuilder().setPurgedEventsCount(-310774833).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeUserEventsResponse actualResponse = client.purgeUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importUserEventsTest() throws Exception { + ImportUserEventsResponse expectedResponse = + ImportUserEventsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setImportSummary(UserEventImportSummary.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + + ImportUserEventsResponse actualResponse = client.importUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + client.importUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rejoinUserEventsTest() throws Exception { + RejoinUserEventsResponse expectedResponse = + RejoinUserEventsResponse.newBuilder().setRejoinedUserEventsCount(-1152281574).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rejoinUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + + RejoinUserEventsResponse actualResponse = client.rejoinUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void rejoinUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + client.rejoinUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CatalogServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CatalogServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..0356ab45ce23 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CatalogServiceClientHttpJsonTest.java @@ -0,0 +1,928 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.CatalogServiceClient.ListCatalogsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonCatalogServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CatalogServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CatalogServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCatalogServiceStub.getMethodDescriptors(), + CatalogServiceSettings.getDefaultEndpoint()); + CatalogServiceSettings settings = + CatalogServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CatalogServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listCatalogsTest() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCatalogsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCatalogsTest2() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCatalogsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCatalogTest() throws Exception { + Catalog expectedResponse = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Catalog actualResponse = client.updateCatalog(catalog, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateCatalogExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCatalog(catalog, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + client.setDefaultBranch(catalog); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + client.setDefaultBranch(catalog); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest2() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + CompletionConfig actualResponse = client.getCompletionConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest2() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + + CompletionConfig actualResponse = client.getCompletionConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getCompletionConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + CompletionConfig actualResponse = client.updateCompletionConfig(completionConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCompletionConfig(completionConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + AttributesConfig actualResponse = client.getAttributesConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest2() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + + AttributesConfig actualResponse = client.getAttributesConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAttributesConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + AttributesConfig actualResponse = client.updateAttributesConfig(attributesConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateAttributesConfig(attributesConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.addCatalogAttribute(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + client.addCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + + AttributesConfig actualResponse = client.removeCatalogAttribute(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + client.removeCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void replaceCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.replaceCatalogAttribute(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void replaceCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.replaceCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CompletionServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CompletionServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..e35582ea67d6 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/CompletionServiceClientHttpJsonTest.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonCompletionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CompletionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CompletionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCompletionServiceStub.getMethodDescriptors(), + CompletionServiceSettings.getDefaultEndpoint()); + CompletionServiceSettings settings = + CompletionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CompletionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void completeQueryTest() throws Exception { + CompleteQueryResponse expectedResponse = + CompleteQueryResponse.newBuilder() + .addAllCompletionResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllRecentSearchResults(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + + CompleteQueryResponse actualResponse = client.completeQuery(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void completeQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + client.completeQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importCompletionDataTest() throws Exception { + ImportCompletionDataResponse expectedResponse = + ImportCompletionDataResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importCompletionDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportCompletionDataResponse actualResponse = client.importCompletionDataAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importCompletionDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importCompletionDataAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ControlServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ControlServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..e02761d62da1 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ControlServiceClientHttpJsonTest.java @@ -0,0 +1,529 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.ControlServiceClient.ListControlsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonControlServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ControlServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ControlServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonControlServiceStub.getMethodDescriptors(), + ControlServiceSettings.getDefaultEndpoint()); + ControlServiceSettings settings = + ControlServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ControlServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + client.deleteControl(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + client.deleteControl(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Control control = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Control actualResponse = client.updateControl(control, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Control control = + Control.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateControl(control, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + Control actualResponse = client.getControl(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .addAllSearchSolutionUseCase(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + Control actualResponse = client.getControl(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listControlsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest2() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listControlsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/PredictionServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..45375173c688 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,145 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonPredictionServiceStub; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class PredictionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static PredictionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPredictionServiceStub.getMethodDescriptors(), + PredictionServiceSettings.getDefaultEndpoint()); + PredictionServiceSettings settings = + PredictionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PredictionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void predictTest() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllMissingIds(new ArrayList()) + .setValidateOnly(true) + .build(); + mockService.addResponse(expectedResponse); + + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + PredictResponse actualResponse = client.predict(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void predictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.predict(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ProductServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ProductServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..41f64d76e275 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ProductServiceClientHttpJsonTest.java @@ -0,0 +1,1361 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.ProductServiceClient.ListProductsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonProductServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ProductServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductServiceStub.getMethodDescriptors(), + ProductServiceSettings.getDefaultEndpoint()); + ProductServiceSettings settings = + ProductServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Product actualResponse = client.updateProduct(product, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProduct(product, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeProductsTest() throws Exception { + PurgeProductsResponse expectedResponse = + PurgeProductsResponse.newBuilder() + .setPurgeCount(575305851) + .addAllPurgeSample(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeProductsResponse actualResponse = client.purgeProductsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importProductsTest() throws Exception { + ImportProductsResponse expectedResponse = + ImportProductsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportProductsResponse actualResponse = client.importProductsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setInventoryTest() throws Exception { + SetInventoryResponse expectedResponse = SetInventoryResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setInventoryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + + SetInventoryResponse actualResponse = client.setInventoryAsync(inventory, setMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + client.setInventoryAsync(inventory, setMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest2() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest2() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest2() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest2() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/SearchServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/SearchServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..508ee667be79 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/SearchServiceClientHttpJsonTest.java @@ -0,0 +1,172 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.SearchServiceClient.SearchPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonSearchServiceStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SearchServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static SearchServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSearchServiceStub.getMethodDescriptors(), + SearchServiceSettings.getDefaultEndpoint()); + SearchServiceSettings settings = + SearchServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SearchServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void searchTest() throws Exception { + SearchResponse.SearchResult responsesElement = SearchResponse.SearchResult.newBuilder().build(); + SearchResponse expectedResponse = + SearchResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + + SearchPagedResponse pagedListResponse = client.search(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + client.search(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..25d4041d00fd --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/ServingConfigServiceClientHttpJsonTest.java @@ -0,0 +1,888 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import static com.google.cloud.retail.v2alpha.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonServingConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ServingConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ServingConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonServingConfigServiceStub.getMethodDescriptors(), + ServingConfigServiceSettings.getDefaultEndpoint()); + ServingConfigServiceSettings settings = + ServingConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ServingConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + client.deleteServingConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + client.deleteServingConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ServingConfig actualResponse = client.updateServingConfig(servingConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateServingConfig(servingConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.getServingConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + ServingConfig actualResponse = client.getServingConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServingConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest2() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServingConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.addControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.addControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.removeControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.removeControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/UserEventServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/UserEventServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..27f1e1c43f50 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2alpha/UserEventServiceClientHttpJsonTest.java @@ -0,0 +1,382 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha; + +import com.google.api.HttpBody; +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2alpha.stub.HttpJsonUserEventServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class UserEventServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static UserEventServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonUserEventServiceStub.getMethodDescriptors(), + UserEventServiceSettings.getDefaultEndpoint()); + UserEventServiceSettings settings = + UserEventServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = UserEventServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void writeUserEventTest() throws Exception { + UserEvent expectedResponse = + UserEvent.newBuilder() + .setEventType("eventType31430900") + .setVisitorId("visitorId1880545833") + .setSessionId("sessionId607796817") + .setEventTime(Timestamp.newBuilder().build()) + .addAllExperimentIds(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllProductDetails(new ArrayList()) + .setCompletionDetail(CompletionDetail.newBuilder().build()) + .putAllAttributes(new HashMap()) + .setCartId("cartId-1367589797") + .setPurchaseTransaction(PurchaseTransaction.newBuilder().build()) + .setSearchQuery("searchQuery-552137728") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setOffset(-1019779949) + .addAllPageCategories(new ArrayList()) + .setUserInfo(UserInfo.newBuilder().build()) + .setUri("uri116076") + .setReferrerUri("referrerUri348088525") + .setPageViewId("pageViewId1362499087") + .build(); + mockService.addResponse(expectedResponse); + + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + + UserEvent actualResponse = client.writeUserEvent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void writeUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + client.writeUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void collectUserEventTest() throws Exception { + HttpBody expectedResponse = + HttpBody.newBuilder() + .setContentType("contentType-389131437") + .setData(ByteString.EMPTY) + .addAllExtensions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + + HttpBody actualResponse = client.collectUserEvent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void collectUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + client.collectUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeUserEventsTest() throws Exception { + PurgeUserEventsResponse expectedResponse = + PurgeUserEventsResponse.newBuilder().setPurgedEventsCount(-310774833).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeUserEventsResponse actualResponse = client.purgeUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importUserEventsTest() throws Exception { + ImportUserEventsResponse expectedResponse = + ImportUserEventsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setImportSummary(UserEventImportSummary.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + + ImportUserEventsResponse actualResponse = client.importUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + client.importUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rejoinUserEventsTest() throws Exception { + RejoinUserEventsResponse expectedResponse = + RejoinUserEventsResponse.newBuilder().setRejoinedUserEventsCount(-1152281574).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rejoinUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + + RejoinUserEventsResponse actualResponse = client.rejoinUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void rejoinUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + client.rejoinUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CatalogServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CatalogServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..83ae3ee5b338 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CatalogServiceClientHttpJsonTest.java @@ -0,0 +1,928 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.CatalogServiceClient.ListCatalogsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonCatalogServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CatalogServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CatalogServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCatalogServiceStub.getMethodDescriptors(), + CatalogServiceSettings.getDefaultEndpoint()); + CatalogServiceSettings settings = + CatalogServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CatalogServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listCatalogsTest() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCatalogsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCatalogsTest2() throws Exception { + Catalog responsesElement = Catalog.newBuilder().build(); + ListCatalogsResponse expectedResponse = + ListCatalogsResponse.newBuilder() + .setNextPageToken("") + .addAllCatalogs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListCatalogsPagedResponse pagedListResponse = client.listCatalogs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCatalogsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCatalogsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listCatalogs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCatalogTest() throws Exception { + Catalog expectedResponse = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Catalog actualResponse = client.updateCatalog(catalog, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateCatalogExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Catalog catalog = + Catalog.newBuilder() + .setName(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setDisplayName("displayName1714148973") + .setProductLevelConfig(ProductLevelConfig.newBuilder().build()) + .setMerchantCenterLinkingConfig(MerchantCenterLinkingConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCatalog(catalog, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + client.setDefaultBranch(catalog); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setDefaultBranchTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + client.setDefaultBranch(catalog); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.setDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDefaultBranchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName catalog = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDefaultBranchTest2() throws Exception { + GetDefaultBranchResponse expectedResponse = + GetDefaultBranchResponse.newBuilder() + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setSetTime(Timestamp.newBuilder().build()) + .setNote("note3387378") + .build(); + mockService.addResponse(expectedResponse); + + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + + GetDefaultBranchResponse actualResponse = client.getDefaultBranch(catalog); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDefaultBranchExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String catalog = "projects/project-6372/locations/location-6372/catalogs/catalog-6372"; + client.getDefaultBranch(catalog); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + CompletionConfig actualResponse = client.getCompletionConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getCompletionConfigTest2() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + + CompletionConfig actualResponse = client.getCompletionConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getCompletionConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6627/locations/location-6627/catalogs/catalog-6627/completionConfig"; + client.getCompletionConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateCompletionConfigTest() throws Exception { + CompletionConfig expectedResponse = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + mockService.addResponse(expectedResponse); + + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + CompletionConfig actualResponse = client.updateCompletionConfig(completionConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateCompletionConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompletionConfig completionConfig = + CompletionConfig.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setMatchingOrder("matchingOrder-1366761135") + .setMaxSuggestions(618824852) + .setMinPrefixLength(96853510) + .setAutoLearning(true) + .setSuggestionsInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastSuggestionsImportOperation("lastSuggestionsImportOperation-245829751") + .setDenylistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastDenylistImportOperation("lastDenylistImportOperation1262341570") + .setAllowlistInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setLastAllowlistImportOperation("lastAllowlistImportOperation1624716689") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateCompletionConfig(completionConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + AttributesConfig actualResponse = client.getAttributesConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAttributesConfigTest2() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + + AttributesConfig actualResponse = client.getAttributesConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAttributesConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9790/locations/location-9790/catalogs/catalog-9790/attributesConfig"; + client.getAttributesConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateAttributesConfigTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + AttributesConfig actualResponse = client.updateAttributesConfig(attributesConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateAttributesConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AttributesConfig attributesConfig = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateAttributesConfig(attributesConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.addCatalogAttribute(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + client.addCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + + AttributesConfig actualResponse = client.removeCatalogAttribute(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + client.removeCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void replaceCatalogAttributeTest() throws Exception { + AttributesConfig expectedResponse = + AttributesConfig.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .putAllCatalogAttributes(new HashMap()) + .setAttributeConfigLevel(AttributeConfigLevel.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + AttributesConfig actualResponse = client.replaceCatalogAttribute(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void replaceCatalogAttributeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.replaceCatalogAttribute(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CompletionServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CompletionServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..286acd1f924f --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/CompletionServiceClientHttpJsonTest.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonCompletionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CompletionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CompletionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCompletionServiceStub.getMethodDescriptors(), + CompletionServiceSettings.getDefaultEndpoint()); + CompletionServiceSettings settings = + CompletionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CompletionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void completeQueryTest() throws Exception { + CompleteQueryResponse expectedResponse = + CompleteQueryResponse.newBuilder() + .addAllCompletionResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllRecentSearchResults(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + + CompleteQueryResponse actualResponse = client.completeQuery(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void completeQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + client.completeQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importCompletionDataTest() throws Exception { + ImportCompletionDataResponse expectedResponse = + ImportCompletionDataResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importCompletionDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportCompletionDataResponse actualResponse = client.importCompletionDataAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importCompletionDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importCompletionDataAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ControlServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ControlServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..78d3f2e48549 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ControlServiceClientHttpJsonTest.java @@ -0,0 +1,522 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.ControlServiceClient.ListControlsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonControlServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ControlServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ControlServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonControlServiceStub.getMethodDescriptors(), + ControlServiceSettings.getDefaultEndpoint()); + ControlServiceSettings settings = + ControlServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ControlServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + + Control actualResponse = client.createControl(parent, control, controlId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + client.createControl(parent, control, controlId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + client.deleteControl(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteControlTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + client.deleteControl(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.deleteControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Control control = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Control actualResponse = client.updateControl(control, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Control control = + Control.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateControl(control, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + + Control actualResponse = client.getControl(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getControlTest2() throws Exception { + Control expectedResponse = + Control.newBuilder() + .setName(ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .setDisplayName("displayName1714148973") + .addAllAssociatedServingConfigIds(new ArrayList()) + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + + Control actualResponse = client.getControl(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7366/locations/location-7366/catalogs/catalog-7366/controls/control-7366"; + client.getControl(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listControlsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listControlsTest2() throws Exception { + Control responsesElement = Control.newBuilder().build(); + ListControlsResponse expectedResponse = + ListControlsResponse.newBuilder() + .setNextPageToken("") + .addAllControls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListControlsPagedResponse pagedListResponse = client.listControls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getControlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listControlsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listControls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/PredictionServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..db9a6ead560b --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,145 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonPredictionServiceStub; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class PredictionServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static PredictionServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPredictionServiceStub.getMethodDescriptors(), + PredictionServiceSettings.getDefaultEndpoint()); + PredictionServiceSettings settings = + PredictionServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PredictionServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void predictTest() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllResults(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllMissingIds(new ArrayList()) + .setValidateOnly(true) + .build(); + mockService.addResponse(expectedResponse); + + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + PredictResponse actualResponse = client.predict(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void predictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.predict(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ProductServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ProductServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..ae36ae72182c --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ProductServiceClientHttpJsonTest.java @@ -0,0 +1,1300 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.ProductServiceClient.ListProductsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonProductServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ProductServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ProductServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProductServiceStub.getMethodDescriptors(), + ProductServiceSettings.getDefaultEndpoint()); + ProductServiceSettings settings = + ProductServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProductServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + + Product actualResponse = client.createProduct(parent, product, productId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + client.createProduct(parent, product, productId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProductTest2() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + Product actualResponse = client.getProduct(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.getProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProductsTest2() throws Exception { + Product responsesElement = Product.newBuilder().build(); + ListProductsResponse expectedResponse = + ListProductsResponse.newBuilder() + .setNextPageToken("") + .addAllProducts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + + ListProductsPagedResponse pagedListResponse = client.listProducts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProductsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listProductsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-7087/locations/location-7087/catalogs/catalog-7087/branches/branche-7087"; + client.listProducts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateProductTest() throws Exception { + Product expectedResponse = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Product actualResponse = client.updateProduct(product, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product product = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProduct(product, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteProductTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + + client.deleteProduct(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteProductExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-436/locations/location-436/catalogs/catalog-436/branches/branche-436/products/product-436"; + client.deleteProduct(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void importProductsTest() throws Exception { + ImportProductsResponse expectedResponse = + ImportProductsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importProductsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + + ImportProductsResponse actualResponse = client.importProductsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importProductsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + client.importProductsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setInventoryTest() throws Exception { + SetInventoryResponse expectedResponse = SetInventoryResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setInventoryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + + SetInventoryResponse actualResponse = client.setInventoryAsync(inventory, setMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Product inventory = + Product.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setId("id3355") + .setPrimaryProductId("primaryProductId-857339256") + .addAllCollectionMemberIds(new ArrayList()) + .setGtin("gtin3183314") + .addAllCategories(new ArrayList()) + .setTitle("title110371416") + .addAllBrands(new ArrayList()) + .setDescription("description-1724546052") + .setLanguageCode("languageCode-2092349083") + .putAllAttributes(new HashMap()) + .addAllTags(new ArrayList()) + .setPriceInfo(PriceInfo.newBuilder().build()) + .setRating(Rating.newBuilder().build()) + .setAvailableTime(Timestamp.newBuilder().build()) + .setAvailableQuantity(Int32Value.newBuilder().build()) + .addAllFulfillmentInfo(new ArrayList()) + .setUri("uri116076") + .addAllImages(new ArrayList()) + .setAudience(Audience.newBuilder().build()) + .setColorInfo(ColorInfo.newBuilder().build()) + .addAllSizes(new ArrayList()) + .addAllMaterials(new ArrayList()) + .addAllPatterns(new ArrayList()) + .addAllConditions(new ArrayList()) + .addAllPromotions(new ArrayList()) + .setPublishTime(Timestamp.newBuilder().build()) + .setRetrievableFields(FieldMask.newBuilder().build()) + .addAllVariants(new ArrayList()) + .build(); + FieldMask setMask = FieldMask.newBuilder().build(); + client.setInventoryAsync(inventory, setMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addFulfillmentPlacesTest2() throws Exception { + AddFulfillmentPlacesResponse expectedResponse = + AddFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddFulfillmentPlacesResponse actualResponse = client.addFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeFulfillmentPlacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeFulfillmentPlacesTest2() throws Exception { + RemoveFulfillmentPlacesResponse expectedResponse = + RemoveFulfillmentPlacesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeFulfillmentPlacesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveFulfillmentPlacesResponse actualResponse = + client.removeFulfillmentPlacesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeFulfillmentPlacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeFulfillmentPlacesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addLocalInventoriesTest2() throws Exception { + AddLocalInventoriesResponse expectedResponse = AddLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + AddLocalInventoriesResponse actualResponse = client.addLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.addLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeLocalInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeLocalInventoriesTest2() throws Exception { + RemoveLocalInventoriesResponse expectedResponse = + RemoveLocalInventoriesResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removeLocalInventoriesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + + RemoveLocalInventoriesResponse actualResponse = + client.removeLocalInventoriesAsync(product).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeLocalInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String product = + "projects/project-3856/locations/location-3856/catalogs/catalog-3856/branches/branche-3856/products/product-3856"; + client.removeLocalInventoriesAsync(product).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/SearchServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/SearchServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..c2e28c528a22 --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/SearchServiceClientHttpJsonTest.java @@ -0,0 +1,172 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.SearchServiceClient.SearchPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonSearchServiceStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SearchServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static SearchServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSearchServiceStub.getMethodDescriptors(), + SearchServiceSettings.getDefaultEndpoint()); + SearchServiceSettings settings = + SearchServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SearchServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void searchTest() throws Exception { + SearchResponse.SearchResult responsesElement = SearchResponse.SearchResult.newBuilder().build(); + SearchResponse expectedResponse = + SearchResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch(BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + + SearchPagedResponse pagedListResponse = client.search(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement( + "projects/project-9512/locations/location-9512/catalogs/catalog-9512/placements/placement-9512") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + client.search(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ServingConfigServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ServingConfigServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..218b82d1a8ca --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/ServingConfigServiceClientHttpJsonTest.java @@ -0,0 +1,888 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import static com.google.cloud.retail.v2beta.ServingConfigServiceClient.ListServingConfigsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonServingConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ServingConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ServingConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonServingConfigServiceStub.getMethodDescriptors(), + ServingConfigServiceSettings.getDefaultEndpoint()); + ServingConfigServiceSettings settings = + ServingConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ServingConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + + ServingConfig actualResponse = + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + client.createServingConfig(parent, servingConfig, servingConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + client.deleteServingConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServingConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + client.deleteServingConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.deleteServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ServingConfig actualResponse = client.updateServingConfig(servingConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfig servingConfig = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateServingConfig(servingConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.getServingConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServingConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServingConfigTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + + ServingConfig actualResponse = client.getServingConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServingConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4507/locations/location-4507/catalogs/catalog-4507/servingConfigs/servingConfig-4507"; + client.getServingConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServingConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServingConfigsTest2() throws Exception { + ServingConfig responsesElement = ServingConfig.newBuilder().build(); + ListServingConfigsResponse expectedResponse = + ListServingConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllServingConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + + ListServingConfigsPagedResponse pagedListResponse = client.listServingConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServingConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServingConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6267/locations/location-6267/catalogs/catalog-6267"; + client.listServingConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.addControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.addControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void addControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.addControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + + ServingConfig actualResponse = client.removeControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeControlExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeControlTest2() throws Exception { + ServingConfig expectedResponse = + ServingConfig.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setModelId("modelId1226956324") + .setPriceRerankingLevel("priceRerankingLevel-1925548982") + .addAllFacetControlIds(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .addAllBoostControlIds(new ArrayList()) + .addAllFilterControlIds(new ArrayList()) + .addAllRedirectControlIds(new ArrayList()) + .addAllTwowaySynonymsControlIds(new ArrayList()) + .addAllOnewaySynonymsControlIds(new ArrayList()) + .addAllDoNotAssociateControlIds(new ArrayList()) + .addAllReplacementControlIds(new ArrayList()) + .addAllIgnoreControlIds(new ArrayList()) + .setDiversityLevel("diversityLevel578206123") + .setEnableCategoryFilterLevel("enableCategoryFilterLevel-1232535413") + .addAllSolutionTypes(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + + ServingConfig actualResponse = client.removeControl(servingConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void removeControlExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String servingConfig = + "projects/project-1064/locations/location-1064/catalogs/catalog-1064/servingConfigs/servingConfig-1064"; + client.removeControl(servingConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/UserEventServiceClientHttpJsonTest.java b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/UserEventServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..3cb9e378f12f --- /dev/null +++ b/java-retail/google-cloud-retail/src/test/java/com/google/cloud/retail/v2beta/UserEventServiceClientHttpJsonTest.java @@ -0,0 +1,382 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta; + +import com.google.api.HttpBody; +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.retail.v2beta.stub.HttpJsonUserEventServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class UserEventServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static UserEventServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonUserEventServiceStub.getMethodDescriptors(), + UserEventServiceSettings.getDefaultEndpoint()); + UserEventServiceSettings settings = + UserEventServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = UserEventServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void writeUserEventTest() throws Exception { + UserEvent expectedResponse = + UserEvent.newBuilder() + .setEventType("eventType31430900") + .setVisitorId("visitorId1880545833") + .setSessionId("sessionId607796817") + .setEventTime(Timestamp.newBuilder().build()) + .addAllExperimentIds(new ArrayList()) + .setAttributionToken("attributionToken104706234") + .addAllProductDetails(new ArrayList()) + .setCompletionDetail(CompletionDetail.newBuilder().build()) + .putAllAttributes(new HashMap()) + .setCartId("cartId-1367589797") + .setPurchaseTransaction(PurchaseTransaction.newBuilder().build()) + .setSearchQuery("searchQuery-552137728") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setOffset(-1019779949) + .addAllPageCategories(new ArrayList()) + .setUserInfo(UserInfo.newBuilder().build()) + .setUri("uri116076") + .setReferrerUri("referrerUri348088525") + .setPageViewId("pageViewId1362499087") + .build(); + mockService.addResponse(expectedResponse); + + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + + UserEvent actualResponse = client.writeUserEvent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void writeUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + client.writeUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void collectUserEventTest() throws Exception { + HttpBody expectedResponse = + HttpBody.newBuilder() + .setContentType("contentType-389131437") + .setData(ByteString.EMPTY) + .addAllExtensions(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + + HttpBody actualResponse = client.collectUserEvent(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void collectUserEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + client.collectUserEvent(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void purgeUserEventsTest() throws Exception { + PurgeUserEventsResponse expectedResponse = + PurgeUserEventsResponse.newBuilder().setPurgedEventsCount(-310774833).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("purgeUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + + PurgeUserEventsResponse actualResponse = client.purgeUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void purgeUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + client.purgeUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importUserEventsTest() throws Exception { + ImportUserEventsResponse expectedResponse = + ImportUserEventsResponse.newBuilder() + .addAllErrorSamples(new ArrayList()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setImportSummary(UserEventImportSummary.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + + ImportUserEventsResponse actualResponse = client.importUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + client.importUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rejoinUserEventsTest() throws Exception { + RejoinUserEventsResponse expectedResponse = + RejoinUserEventsResponse.newBuilder().setRejoinedUserEventsCount(-1152281574).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rejoinUserEventsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + + RejoinUserEventsResponse actualResponse = client.rejoinUserEventsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void rejoinUserEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder() + .setParent("projects/project-6267/locations/location-6267/catalogs/catalog-6267") + .build(); + client.rejoinUserEventsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..213b179d2d5b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.CatalogServiceSettings; +import com.google.cloud.retail.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // 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); + } +} +// [END retail_v2_generated_catalogserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..681344e3f8dc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.CatalogServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2_generated_catalogserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..e0e3954b263d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.CatalogServiceSettings; +import com.google.cloud.retail.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // 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); + } +} +// [END retail_v2_generated_catalogserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java new file mode 100644 index 000000000000..4623f87554d0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchRequest; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class AsyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncGetDefaultBranch(); + } + + public static void asyncGetDefaultBranch() throws Exception { + // 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 future = + catalogServiceClient.getDefaultBranchCallable().futureCall(request); + // Do something. + GetDefaultBranchResponse response = future.get(); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java new file mode 100644 index 000000000000..f04e784c6acc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchRequest; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class SyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranch(); + } + + public static void syncGetDefaultBranch() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java new file mode 100644 index 000000000000..777cfc448e53 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchCatalogname(); + } + + public static void syncGetDefaultBranchCatalogname() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java new file mode 100644 index 000000000000..f572a6abcf73 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_getdefaultbranch_string_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchString(); + } + + public static void syncGetDefaultBranchString() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_getdefaultbranch_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogs.java new file mode 100644 index 000000000000..777b11bbfdfa --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.LocationName; + +public class AsyncListCatalogs { + + public static void main(String[] args) throws Exception { + asyncListCatalogs(); + } + + public static void asyncListCatalogs() throws Exception { + // 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 future = + catalogServiceClient.listCatalogsPagedCallable().futureCall(request); + // Do something. + for (Catalog element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java new file mode 100644 index 000000000000..da1fe655400f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_paged_async] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.ListCatalogsResponse; +import com.google.cloud.retail.v2.LocationName; +import com.google.common.base.Strings; + +public class AsyncListCatalogsPaged { + + public static void main(String[] args) throws Exception { + asyncListCatalogsPaged(); + } + + public static void asyncListCatalogsPaged() throws Exception { + // 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.getCatalogsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogs.java new file mode 100644 index 000000000000..0ec31dfc94af --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogs.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.ListCatalogsRequest; +import com.google.cloud.retail.v2.LocationName; + +public class SyncListCatalogs { + + public static void main(String[] args) throws Exception { + syncListCatalogs(); + } + + public static void syncListCatalogs() throws Exception { + // 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); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java new file mode 100644 index 000000000000..1cc7c8932bb4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_locationname_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.LocationName; + +public class SyncListCatalogsLocationname { + + public static void main(String[] args) throws Exception { + syncListCatalogsLocationname(); + } + + public static void syncListCatalogsLocationname() throws Exception { + // 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); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_locationname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsString.java new file mode 100644 index 000000000000..b5b5abfebf10 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/listcatalogs/SyncListCatalogsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_listcatalogs_string_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.LocationName; + +public class SyncListCatalogsString { + + public static void main(String[] args) throws Exception { + syncListCatalogsString(); + } + + public static void syncListCatalogsString() throws Exception { + // 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); + } + } + } +} +// [END retail_v2_generated_catalogserviceclient_listcatalogs_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java new file mode 100644 index 000000000000..e3555dcbe6f0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class AsyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncSetDefaultBranch(); + } + + public static void asyncSetDefaultBranch() throws Exception { + // 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 future = catalogServiceClient.setDefaultBranchCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java new file mode 100644 index 000000000000..ecab749e6680 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranch(); + } + + public static void syncSetDefaultBranch() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java new file mode 100644 index 000000000000..eb670199ff5b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchCatalogname(); + } + + public static void syncSetDefaultBranchCatalogname() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java new file mode 100644 index 000000000000..55407bc053a4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_setdefaultbranch_string_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchString(); + } + + public static void syncSetDefaultBranchString() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_setdefaultbranch_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java new file mode 100644 index 000000000000..265bbe0288ca --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_updatecatalog_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + asyncUpdateCatalog(); + } + + public static void asyncUpdateCatalog() throws Exception { + // 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 future = catalogServiceClient.updateCatalogCallable().futureCall(request); + // Do something. + Catalog response = future.get(); + } + } +} +// [END retail_v2_generated_catalogserviceclient_updatecatalog_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..f16c63918fc9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_updatecatalog_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.cloud.retail.v2.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java new file mode 100644 index 000000000000..874e774c79e0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] +import com.google.cloud.retail.v2.Catalog; +import com.google.cloud.retail.v2.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalogCatalogFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCatalogCatalogFieldmask(); + } + + public static void syncUpdateCatalogCatalogFieldmask() throws Exception { + // 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); + } + } +} +// [END retail_v2_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..4234849a78e7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_catalogservicesettings_updatecatalog_sync] +import com.google.cloud.retail.v2.CatalogServiceSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_catalogservicesettings_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/AsyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/AsyncCompleteQuery.java new file mode 100644 index 000000000000..8bc7306a37f4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/AsyncCompleteQuery.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_completequery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompleteQueryRequest; +import com.google.cloud.retail.v2.CompleteQueryResponse; +import com.google.cloud.retail.v2.CompletionServiceClient; +import java.util.ArrayList; + +public class AsyncCompleteQuery { + + public static void main(String[] args) throws Exception { + asyncCompleteQuery(); + } + + public static void asyncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + ApiFuture future = + completionServiceClient.completeQueryCallable().futureCall(request); + // Do something. + CompleteQueryResponse response = future.get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_completequery_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..374718c66c90 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/completequery/SyncCompleteQuery.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_completequery_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompleteQueryRequest; +import com.google.cloud.retail.v2.CompleteQueryResponse; +import com.google.cloud.retail.v2.CompletionServiceClient; +import java.util.ArrayList; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + CompleteQueryResponse response = completionServiceClient.completeQuery(request); + } + } +} +// [END retail_v2_generated_completionserviceclient_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..1160a4825c1f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.CompletionServiceSettings; +import com.google.cloud.retail.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2_generated_completionserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..d0eb8e1ebff5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.CompletionServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2_generated_completionserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..7f5bd37d4316 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.CompletionServiceSettings; +import com.google.cloud.retail.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2_generated_completionserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java new file mode 100644 index 000000000000..92d0eb44e005 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_importcompletiondata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompletionDataInputConfig; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.longrunning.Operation; + +public class AsyncImportCompletionData { + + public static void main(String[] args) throws Exception { + asyncImportCompletionData(); + } + + public static void asyncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + completionServiceClient.importCompletionDataCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_importcompletiondata_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java new file mode 100644 index 000000000000..4c6d81434ce1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_importcompletiondata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompletionDataInputConfig; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.cloud.retail.v2.ImportCompletionDataResponse; +import com.google.cloud.retail.v2.ImportMetadata; + +public class AsyncImportCompletionDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportCompletionDataLRO(); + } + + public static void asyncImportCompletionDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + completionServiceClient.importCompletionDataOperationCallable().futureCall(request); + // Do something. + ImportCompletionDataResponse response = future.get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_importcompletiondata_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/SyncImportCompletionData.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/SyncImportCompletionData.java new file mode 100644 index 000000000000..0640ce07e82a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionserviceclient/importcompletiondata/SyncImportCompletionData.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionserviceclient_importcompletiondata_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.CompletionDataInputConfig; +import com.google.cloud.retail.v2.CompletionServiceClient; +import com.google.cloud.retail.v2.ImportCompletionDataRequest; +import com.google.cloud.retail.v2.ImportCompletionDataResponse; + +public class SyncImportCompletionData { + + public static void main(String[] args) throws Exception { + syncImportCompletionData(); + } + + public static void syncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportCompletionDataResponse response = + completionServiceClient.importCompletionDataAsync(request).get(); + } + } +} +// [END retail_v2_generated_completionserviceclient_importcompletiondata_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionservicesettings/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionservicesettings/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..ee8cc26fc596 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/completionservicesettings/completequery/SyncCompleteQuery.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_completionservicesettings_completequery_sync] +import com.google.cloud.retail.v2.CompletionServiceSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings.Builder completionServiceSettingsBuilder = + CompletionServiceSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceSettings completionServiceSettings = completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_completionservicesettings_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..df7905537f7f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.PredictionServiceSettings; +import com.google.cloud.retail.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..6145428b3d72 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.PredictionServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..a018130400c5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.PredictionServiceSettings; +import com.google.cloud.retail.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/AsyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 000000000000..bcf63d22c8dc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/AsyncPredict.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.PredictRequest; +import com.google.cloud.retail.v2.PredictResponse; +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class AsyncPredict { + + public static void main(String[] args) throws Exception { + asyncPredict(); + } + + public static void asyncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END retail_v2_generated_predictionserviceclient_predict_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 000000000000..e7892b77f720 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionserviceclient/predict/SyncPredict.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_predictionserviceclient_predict_sync] +import com.google.cloud.retail.v2.PredictRequest; +import com.google.cloud.retail.v2.PredictResponse; +import com.google.cloud.retail.v2.PredictionServiceClient; +import com.google.cloud.retail.v2.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END retail_v2_generated_predictionserviceclient_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionservicesettings/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 000000000000..4fcbd0c7b814 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/predictionservicesettings/predict/SyncPredict.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_predictionservicesettings_predict_sync] +import com.google.cloud.retail.v2.PredictionServiceSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceSettings predictionServiceSettings = predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_predictionservicesettings_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java new file mode 100644 index 000000000000..b86d2b101c93 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlaces(); + } + + public static void asyncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java new file mode 100644 index 000000000000..751a38213110 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlacesLRO(); + } + + public static void asyncAddFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + AddFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java new file mode 100644 index 000000000000..922a67007e65 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_sync] +import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlaces(); + } + + public static void syncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java new file mode 100644 index 000000000000..00890d1ce18c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesProductname(); + } + + public static void syncAddFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java new file mode 100644 index 000000000000..9c0abfa5b023 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addfulfillmentplaces_string_sync] +import com.google.cloud.retail.v2.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesString(); + } + + public static void syncAddFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addfulfillmentplaces_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java new file mode 100644 index 000000000000..806295dcc98a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.LocalInventory; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventories(); + } + + public static void asyncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java new file mode 100644 index 000000000000..0392d8bfd97a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.LocalInventory; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventoriesLRO(); + } + + public static void asyncAddLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addLocalInventoriesOperationCallable().futureCall(request); + // Do something. + AddLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventories.java new file mode 100644 index 000000000000..5e7e76ba6475 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_sync] +import com.google.cloud.retail.v2.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.LocalInventory; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + syncAddLocalInventories(); + } + + public static void syncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java new file mode 100644 index 000000000000..588b3ea51f58 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_productname_sync] +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesProductname(); + } + + public static void syncAddLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java new file mode 100644 index 000000000000..0fd56bef717e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_addlocalinventories_string_sync] +import com.google.cloud.retail.v2.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncAddLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesString(); + } + + public static void syncAddLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_addlocalinventories_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..544d12a98e16 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.ProductServiceSettings; +import com.google.cloud.retail.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2_generated_productserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..ac022062fc1e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.ProductServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2_generated_productserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..ed296bc5182b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.ProductServiceSettings; +import com.google.cloud.retail.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2_generated_productserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/AsyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 000000000000..9f55451aaa36 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/AsyncCreateProduct.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CreateProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class AsyncCreateProduct { + + public static void main(String[] args) throws Exception { + asyncCreateProduct(); + } + + public static void asyncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productServiceClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..b25744093dc8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.CreateProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productServiceClient.createProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java new file mode 100644 index 000000000000..39b84f6adfb1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_branchnameproductstring_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncCreateProductBranchnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductBranchnameProductString(); + } + + public static void syncCreateProductBranchnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_branchnameproductstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductStringProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 000000000000..9efaa3ba1819 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/createproduct/SyncCreateProductStringProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_createproduct_stringproductstring_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncCreateProductStringProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductStringProductString(); + } + + public static void syncCreateProductStringProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2_generated_productserviceclient_createproduct_stringproductstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/AsyncDeleteProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 000000000000..1b7eb9e299b5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/AsyncDeleteProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.DeleteProductRequest; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteProduct { + + public static void main(String[] args) throws Exception { + asyncDeleteProduct(); + } + + public static void asyncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 000000000000..a0f6e454d0c9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_sync] +import com.google.cloud.retail.v2.DeleteProductRequest; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProduct { + + public static void main(String[] args) throws Exception { + syncDeleteProduct(); + } + + public static void syncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + productServiceClient.deleteProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 000000000000..fac9b0d34373 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductProductname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_productname_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProductProductname { + + public static void main(String[] args) throws Exception { + syncDeleteProductProductname(); + } + + public static void syncDeleteProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 000000000000..016875ad1e34 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/deleteproduct/SyncDeleteProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_deleteproduct_string_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProductString { + + public static void main(String[] args) throws Exception { + syncDeleteProductString(); + } + + public static void syncDeleteProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_deleteproduct_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/AsyncGetProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/AsyncGetProduct.java new file mode 100644 index 000000000000..f0a052d1c004 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/AsyncGetProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.GetProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class AsyncGetProduct { + + public static void main(String[] args) throws Exception { + asyncGetProduct(); + } + + public static void asyncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProduct.java new file mode 100644 index 000000000000..27bde94e0763 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_sync] +import com.google.cloud.retail.v2.GetProductRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncGetProduct { + + public static void main(String[] args) throws Exception { + syncGetProduct(); + } + + public static void syncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + Product response = productServiceClient.getProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 000000000000..b3552c643310 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductProductname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_productname_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncGetProductProductname { + + public static void main(String[] args) throws Exception { + syncGetProductProductname(); + } + + public static void syncGetProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductString.java new file mode 100644 index 000000000000..b4f4a21d6c4e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/getproduct/SyncGetProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_getproduct_string_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncGetProductString { + + public static void main(String[] args) throws Exception { + syncGetProductString(); + } + + public static void syncGetProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2_generated_productserviceclient_getproduct_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProducts.java new file mode 100644 index 000000000000..4565e5343a2c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_importproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ProductInputConfig; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncImportProducts { + + public static void main(String[] args) throws Exception { + asyncImportProducts(); + } + + public static void asyncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + productServiceClient.importProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_importproducts_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProductsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProductsLRO.java new file mode 100644 index 000000000000..44115d879d68 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/AsyncImportProductsLRO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_importproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ImportProductsResponse; +import com.google.cloud.retail.v2.ProductInputConfig; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncImportProductsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductsLRO(); + } + + public static void asyncImportProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + productServiceClient.importProductsOperationCallable().futureCall(request); + // Do something. + ImportProductsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_importproducts_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/SyncImportProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/SyncImportProducts.java new file mode 100644 index 000000000000..f0d74b8ac2a0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/importproducts/SyncImportProducts.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_importproducts_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportProductsRequest; +import com.google.cloud.retail.v2.ImportProductsResponse; +import com.google.cloud.retail.v2.ProductInputConfig; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncImportProducts { + + public static void main(String[] args) throws Exception { + syncImportProducts(); + } + + public static void syncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportProductsResponse response = productServiceClient.importProductsAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_importproducts_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProducts.java new file mode 100644 index 000000000000..44b243d46fb7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProducts.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncListProducts { + + public static void main(String[] args) throws Exception { + asyncListProducts(); + } + + public static void asyncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + productServiceClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProductsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 000000000000..f156b90b70d0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_paged_async] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.ListProductsResponse; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +public class AsyncListProductsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsPaged(); + } + + public static void asyncListProductsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + while (true) { + ListProductsResponse response = productServiceClient.listProductsCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProducts.java new file mode 100644 index 000000000000..cd748e1a4691 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProducts.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.ListProductsRequest; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncListProducts { + + public static void main(String[] args) throws Exception { + syncListProducts(); + } + + public static void syncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + for (Product element : productServiceClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsBranchname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsBranchname.java new file mode 100644 index 000000000000..e3a9fb37a53b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsBranchname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_branchname_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncListProductsBranchname { + + public static void main(String[] args) throws Exception { + syncListProductsBranchname(); + } + + public static void syncListProductsBranchname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_branchname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsString.java new file mode 100644 index 000000000000..8e3d4cebe4e9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/listproducts/SyncListProductsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_listproducts_string_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; + +public class SyncListProductsString { + + public static void main(String[] args) throws Exception { + syncListProductsString(); + } + + public static void syncListProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_productserviceclient_listproducts_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java new file mode 100644 index 000000000000..9b3c1f6f3aaf --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlaces(); + } + + public static void asyncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java new file mode 100644 index 000000000000..43ca12855107 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlacesLRO(); + } + + public static void asyncRemoveFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + RemoveFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java new file mode 100644 index 000000000000..27a695a82600 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlaces(); + } + + public static void syncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java new file mode 100644 index 000000000000..11bc11dadbb2 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesProductname(); + } + + public static void syncRemoveFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java new file mode 100644 index 000000000000..9814b7a42344 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removefulfillmentplaces_string_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesString(); + } + + public static void syncRemoveFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removefulfillmentplaces_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java new file mode 100644 index 000000000000..e42c81f3319c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventories(); + } + + public static void asyncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java new file mode 100644 index 000000000000..a4447d031644 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventoriesLRO(); + } + + public static void asyncRemoveLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeLocalInventoriesOperationCallable().futureCall(request); + // Do something. + RemoveLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java new file mode 100644 index 000000000000..e6059c6164f4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventories(); + } + + public static void syncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java new file mode 100644 index 000000000000..ba6b8a17add9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_productname_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesProductname(); + } + + public static void syncRemoveLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java new file mode 100644 index 000000000000..e6a003aedf5e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_removelocalinventories_string_sync] +import com.google.cloud.retail.v2.ProductName; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesString(); + } + + public static void syncRemoveLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_removelocalinventories_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventory.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventory.java new file mode 100644 index 000000000000..55edfe0e44a4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventory.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventory { + + public static void main(String[] args) throws Exception { + asyncSetInventory(); + } + + public static void asyncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.setInventoryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventoryLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventoryLRO.java new file mode 100644 index 000000000000..99544069c6eb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/AsyncSetInventoryLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryMetadata; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventoryLRO { + + public static void main(String[] args) throws Exception { + asyncSetInventoryLRO(); + } + + public static void asyncSetInventoryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.setInventoryOperationCallable().futureCall(request); + // Do something. + SetInventoryResponse response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventory.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventory.java new file mode 100644 index 000000000000..87696f9d4918 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventory.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryRequest; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncSetInventory { + + public static void main(String[] args) throws Exception { + syncSetInventory(); + } + + public static void syncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + SetInventoryResponse response = productServiceClient.setInventoryAsync(request).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java new file mode 100644 index 000000000000..ca30fabad4bf --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_setinventory_productfieldmask_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.SetInventoryResponse; +import com.google.protobuf.FieldMask; + +public class SyncSetInventoryProductFieldmask { + + public static void main(String[] args) throws Exception { + syncSetInventoryProductFieldmask(); + } + + public static void syncSetInventoryProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product inventory = Product.newBuilder().build(); + FieldMask setMask = FieldMask.newBuilder().build(); + SetInventoryResponse response = + productServiceClient.setInventoryAsync(inventory, setMask).get(); + } + } +} +// [END retail_v2_generated_productserviceclient_setinventory_productfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/AsyncUpdateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 000000000000..d8640a10d074 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/AsyncUpdateProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProduct { + + public static void main(String[] args) throws Exception { + asyncUpdateProduct(); + } + + public static void asyncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2_generated_productserviceclient_updateproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 000000000000..e0e6d1a10757 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_updateproduct_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.cloud.retail.v2.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProduct { + + public static void main(String[] args) throws Exception { + syncUpdateProduct(); + } + + public static void syncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + Product response = productServiceClient.updateProduct(request); + } + } +} +// [END retail_v2_generated_productserviceclient_updateproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 000000000000..7dd7ebff81b0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productserviceclient_updateproduct_productfieldmask_sync] +import com.google.cloud.retail.v2.Product; +import com.google.cloud.retail.v2.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductProductFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductProductFieldmask(); + } + + public static void syncUpdateProductProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productServiceClient.updateProduct(product, updateMask); + } + } +} +// [END retail_v2_generated_productserviceclient_updateproduct_productfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productservicesettings/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productservicesettings/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..f7acec58460d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/productservicesettings/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_productservicesettings_createproduct_sync] +import com.google.cloud.retail.v2.ProductServiceSettings; +import java.time.Duration; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings.Builder productServiceSettingsBuilder = + ProductServiceSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_productservicesettings_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..9918465b8df9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.SearchServiceSettings; +import com.google.cloud.retail.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2_generated_searchserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..156129ebd266 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.SearchServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2_generated_searchserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..a4df307a658d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.SearchServiceSettings; +import com.google.cloud.retail.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2_generated_searchserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearch.java new file mode 100644 index 000000000000..3d7850f37ec0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearch.java @@ -0,0 +1,72 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_search_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.UserInfo; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncSearch { + + public static void main(String[] args) throws Exception { + asyncSearch(); + } + + public static void asyncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + ApiFuture future = + searchServiceClient.searchPagedCallable().futureCall(request); + // Do something. + for (SearchResponse.SearchResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_searchserviceclient_search_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearchPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearchPaged.java new file mode 100644 index 000000000000..c5d485cba2b8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/AsyncSearchPaged.java @@ -0,0 +1,78 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_search_paged_async] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.UserInfo; +import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncSearchPaged { + + public static void main(String[] args) throws Exception { + asyncSearchPaged(); + } + + public static void asyncSearchPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + while (true) { + SearchResponse response = searchServiceClient.searchCallable().call(request); + for (SearchResponse.SearchResult element : response.getResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2_generated_searchserviceclient_search_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/SyncSearch.java new file mode 100644 index 000000000000..f03bf0cef925 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchserviceclient/search/SyncSearch.java @@ -0,0 +1,68 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchserviceclient_search_sync] +import com.google.cloud.retail.v2.BranchName; +import com.google.cloud.retail.v2.SearchRequest; +import com.google.cloud.retail.v2.SearchResponse; +import com.google.cloud.retail.v2.SearchServiceClient; +import com.google.cloud.retail.v2.UserInfo; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .putAllLabels(new HashMap()) + .setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build()) + .build(); + for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2_generated_searchserviceclient_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchservicesettings/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchservicesettings/search/SyncSearch.java new file mode 100644 index 000000000000..a240556a2f41 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/searchservicesettings/search/SyncSearch.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_searchservicesettings_search_sync] +import com.google.cloud.retail.v2.SearchServiceSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings.Builder searchServiceSettingsBuilder = SearchServiceSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_searchservicesettings_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..30150799e665 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub.samples; + +// [START retail_v2_generated_catalogservicestubsettings_updatecatalog_sync] +import com.google.cloud.retail.v2.stub.CatalogServiceStubSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceStubSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceStubSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceStubSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_catalogservicestubsettings_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..035c3f0042ab --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub.samples; + +// [START retail_v2_generated_completionservicestubsettings_completequery_sync] +import com.google.cloud.retail.v2.stub.CompletionServiceStubSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceStubSettings.Builder completionServiceSettingsBuilder = + CompletionServiceStubSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceStubSettings completionServiceSettings = + completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_completionservicestubsettings_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/predictionservicestubsettings/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 000000000000..cfc9f7cdcf21 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/predictionservicestubsettings/predict/SyncPredict.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub.samples; + +// [START retail_v2_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.retail.v2.stub.PredictionServiceStubSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceStubSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceStubSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceStubSettings predictionServiceSettings = + predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_predictionservicestubsettings_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/productservicestubsettings/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/productservicestubsettings/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..5dd52b9a7951 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/productservicestubsettings/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub.samples; + +// [START retail_v2_generated_productservicestubsettings_createproduct_sync] +import com.google.cloud.retail.v2.stub.ProductServiceStubSettings; +import java.time.Duration; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceStubSettings.Builder productServiceSettingsBuilder = + ProductServiceStubSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceStubSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_productservicestubsettings_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/searchservicestubsettings/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/searchservicestubsettings/search/SyncSearch.java new file mode 100644 index 000000000000..61a39787c471 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/searchservicestubsettings/search/SyncSearch.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub.samples; + +// [START retail_v2_generated_searchservicestubsettings_search_sync] +import com.google.cloud.retail.v2.stub.SearchServiceStubSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceStubSettings.Builder searchServiceSettingsBuilder = + SearchServiceStubSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceStubSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_searchservicestubsettings_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..c6f601c6ba14 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.stub.samples; + +// [START retail_v2_generated_usereventservicestubsettings_writeuserevent_sync] +import com.google.cloud.retail.v2.stub.UserEventServiceStubSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceStubSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceStubSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceStubSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_usereventservicestubsettings_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java new file mode 100644 index 000000000000..2dc7618c806e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_collectuserevent_async] +import com.google.api.HttpBody; +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CollectUserEventRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + asyncCollectUserEvent(); + } + + public static void asyncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + ApiFuture future = + userEventServiceClient.collectUserEventCallable().futureCall(request); + // Do something. + HttpBody response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_collectuserevent_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java new file mode 100644 index 000000000000..d8877b3c2401 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_collectuserevent_sync] +import com.google.api.HttpBody; +import com.google.cloud.retail.v2.CollectUserEventRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + syncCollectUserEvent(); + } + + public static void syncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + HttpBody response = userEventServiceClient.collectUserEvent(request); + } + } +} +// [END retail_v2_generated_usereventserviceclient_collectuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..e48c52a5e89a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.UserEventServiceSettings; +import com.google.cloud.retail.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2_generated_usereventserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..503196d6f053 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.UserEventServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2_generated_usereventserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..ab23c7c28dde --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.UserEventServiceSettings; +import com.google.cloud.retail.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2_generated_usereventserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEvents.java new file mode 100644 index 000000000000..77a16c76b29b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEvents.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_importuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.UserEventInputConfig; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncImportUserEvents { + + public static void main(String[] args) throws Exception { + asyncImportUserEvents(); + } + + public static void asyncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.importUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_importuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java new file mode 100644 index 000000000000..7ea122a3a50d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_importuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportMetadata; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.ImportUserEventsResponse; +import com.google.cloud.retail.v2.UserEventInputConfig; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncImportUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncImportUserEventsLRO(); + } + + public static void asyncImportUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + OperationFuture future = + userEventServiceClient.importUserEventsOperationCallable().futureCall(request); + // Do something. + ImportUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_importuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/SyncImportUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/SyncImportUserEvents.java new file mode 100644 index 000000000000..db6e00daf725 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/importuserevents/SyncImportUserEvents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_importuserevents_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.ImportErrorsConfig; +import com.google.cloud.retail.v2.ImportUserEventsRequest; +import com.google.cloud.retail.v2.ImportUserEventsResponse; +import com.google.cloud.retail.v2.UserEventInputConfig; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncImportUserEvents { + + public static void main(String[] args) throws Exception { + syncImportUserEvents(); + } + + public static void syncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ImportUserEventsResponse response = + userEventServiceClient.importUserEventsAsync(request).get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_importuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java new file mode 100644 index 000000000000..796729271a44 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_purgeuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEvents(); + } + + public static void asyncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + userEventServiceClient.purgeUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_purgeuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java new file mode 100644 index 000000000000..0ef970d5dcb6 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_purgeuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.PurgeMetadata; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.PurgeUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncPurgeUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEventsLRO(); + } + + public static void asyncPurgeUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + userEventServiceClient.purgeUserEventsOperationCallable().futureCall(request); + // Do something. + PurgeUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_purgeuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java new file mode 100644 index 000000000000..ec0517935a69 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_purgeuserevents_sync] +import com.google.cloud.retail.v2.CatalogName; +import com.google.cloud.retail.v2.PurgeUserEventsRequest; +import com.google.cloud.retail.v2.PurgeUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + syncPurgeUserEvents(); + } + + public static void syncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeUserEventsResponse response = userEventServiceClient.purgeUserEventsAsync(request).get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_purgeuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java new file mode 100644 index 000000000000..a35efcfb482c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_rejoinuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEvents(); + } + + public static void asyncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + ApiFuture future = + userEventServiceClient.rejoinUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_rejoinuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java new file mode 100644 index 000000000000..71f47931dc2c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_rejoinuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.RejoinUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class AsyncRejoinUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEventsLRO(); + } + + public static void asyncRejoinUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + OperationFuture future = + userEventServiceClient.rejoinUserEventsOperationCallable().futureCall(request); + // Do something. + RejoinUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_rejoinuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java new file mode 100644 index 000000000000..57cfbdfb1de6 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_rejoinuserevents_sync] +import com.google.cloud.retail.v2.RejoinUserEventsRequest; +import com.google.cloud.retail.v2.RejoinUserEventsResponse; +import com.google.cloud.retail.v2.UserEventServiceClient; + +public class SyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + syncRejoinUserEvents(); + } + + public static void syncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + RejoinUserEventsResponse response = + userEventServiceClient.rejoinUserEventsAsync(request).get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_rejoinuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java new file mode 100644 index 000000000000..1658e2e571dc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_writeuserevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2.UserEvent; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.WriteUserEventRequest; + +public class AsyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + asyncWriteUserEvent(); + } + + public static void asyncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.writeUserEventCallable().futureCall(request); + // Do something. + UserEvent response = future.get(); + } + } +} +// [END retail_v2_generated_usereventserviceclient_writeuserevent_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..7e0d38011e50 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventserviceclient_writeuserevent_sync] +import com.google.cloud.retail.v2.UserEvent; +import com.google.cloud.retail.v2.UserEventServiceClient; +import com.google.cloud.retail.v2.WriteUserEventRequest; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + UserEvent response = userEventServiceClient.writeUserEvent(request); + } + } +} +// [END retail_v2_generated_usereventserviceclient_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..c78dc1ada06e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2.samples; + +// [START retail_v2_generated_usereventservicesettings_writeuserevent_sync] +import com.google.cloud.retail.v2.UserEventServiceSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2_generated_usereventservicesettings_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java new file mode 100644 index 000000000000..f2ddf1c3d9ed --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class AsyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncAddCatalogAttribute(); + } + + public static void asyncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.addCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java new file mode 100644 index 000000000000..3bd3a620ba2c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_sync] +import com.google.cloud.retail.v2alpha.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class SyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncAddCatalogAttribute(); + } + + public static void syncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.addCatalogAttribute(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_addcatalogattribute_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..19b4334a4fe5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // 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); + } +} +// [END retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..cbddda902630 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2alpha_generated_catalogserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..f2439d8216b9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // 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); + } +} +// [END retail_v2alpha_generated_catalogserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java new file mode 100644 index 000000000000..40a050c022fd --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetAttributesConfigRequest; + +public class AsyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncGetAttributesConfig(); + } + + public static void asyncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java new file mode 100644 index 000000000000..97fd6b8e4298 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetAttributesConfigRequest; + +public class SyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfig(); + } + + public static void syncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java new file mode 100644 index 000000000000..e248cd3bfddd --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class SyncGetAttributesConfigAttributesconfigname { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigAttributesconfigname(); + } + + public static void syncGetAttributesConfigAttributesconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java new file mode 100644 index 000000000000..6ceaba9d1e66 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getattributesconfig_string_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; + +public class SyncGetAttributesConfigString { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigString(); + } + + public static void syncGetAttributesConfigString() throws Exception { + // 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 name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getattributesconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java new file mode 100644 index 000000000000..fcc35a598380 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; +import com.google.cloud.retail.v2alpha.GetCompletionConfigRequest; + +public class AsyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncGetCompletionConfig(); + } + + public static void asyncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java new file mode 100644 index 000000000000..df66713f1939 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; +import com.google.cloud.retail.v2alpha.GetCompletionConfigRequest; + +public class SyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfig(); + } + + public static void syncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java new file mode 100644 index 000000000000..ef084d632c03 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; + +public class SyncGetCompletionConfigCompletionconfigname { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigCompletionconfigname(); + } + + public static void syncGetCompletionConfigCompletionconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java new file mode 100644 index 000000000000..ab4d9e4c795f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_string_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.CompletionConfigName; + +public class SyncGetCompletionConfigString { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigString(); + } + + public static void syncGetCompletionConfigString() throws Exception { + // 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 name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getcompletionconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java new file mode 100644 index 000000000000..f237b8ded356 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class AsyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncGetDefaultBranch(); + } + + public static void asyncGetDefaultBranch() throws Exception { + // 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 future = + catalogServiceClient.getDefaultBranchCallable().futureCall(request); + // Do something. + GetDefaultBranchResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java new file mode 100644 index 000000000000..b279f1f453af --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchRequest; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class SyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranch(); + } + + public static void syncGetDefaultBranch() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java new file mode 100644 index 000000000000..88652dc119de --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchCatalogname(); + } + + public static void syncGetDefaultBranchCatalogname() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java new file mode 100644 index 000000000000..919d905652a1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchString(); + } + + public static void syncGetDefaultBranchString() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_getdefaultbranch_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogs.java new file mode 100644 index 000000000000..5da2583afb80 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.LocationName; + +public class AsyncListCatalogs { + + public static void main(String[] args) throws Exception { + asyncListCatalogs(); + } + + public static void asyncListCatalogs() throws Exception { + // 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 future = + catalogServiceClient.listCatalogsPagedCallable().futureCall(request); + // Do something. + for (Catalog element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java new file mode 100644 index 000000000000..9c7dadd26e52 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_paged_async] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.ListCatalogsResponse; +import com.google.cloud.retail.v2alpha.LocationName; +import com.google.common.base.Strings; + +public class AsyncListCatalogsPaged { + + public static void main(String[] args) throws Exception { + asyncListCatalogsPaged(); + } + + public static void asyncListCatalogsPaged() throws Exception { + // 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.getCatalogsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogs.java new file mode 100644 index 000000000000..c4190187dbca --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogs.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ListCatalogsRequest; +import com.google.cloud.retail.v2alpha.LocationName; + +public class SyncListCatalogs { + + public static void main(String[] args) throws Exception { + syncListCatalogs(); + } + + public static void syncListCatalogs() throws Exception { + // 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); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java new file mode 100644 index 000000000000..93dee5a947f7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_locationname_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.LocationName; + +public class SyncListCatalogsLocationname { + + public static void main(String[] args) throws Exception { + syncListCatalogsLocationname(); + } + + public static void syncListCatalogsLocationname() throws Exception { + // 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); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_locationname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsString.java new file mode 100644 index 000000000000..b4a4cdcaa7d5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/listcatalogs/SyncListCatalogsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_listcatalogs_string_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.LocationName; + +public class SyncListCatalogsString { + + public static void main(String[] args) throws Exception { + syncListCatalogsString(); + } + + public static void syncListCatalogsString() throws Exception { + // 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); + } + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_listcatalogs_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java new file mode 100644 index 000000000000..b4545e2a87de --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + +public class AsyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncRemoveCatalogAttribute(); + } + + public static void asyncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + ApiFuture future = + catalogServiceClient.removeCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java new file mode 100644 index 000000000000..21f18c85c343 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + +public class SyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncRemoveCatalogAttribute(); + } + + public static void syncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + AttributesConfig response = catalogServiceClient.removeCatalogAttribute(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_removecatalogattribute_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java new file mode 100644 index 000000000000..b9bc1b802c6d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncReplaceCatalogAttribute(); + } + + public static void asyncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.replaceCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java new file mode 100644 index 000000000000..772df1460c8f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.AttributesConfigName; +import com.google.cloud.retail.v2alpha.CatalogAttribute; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class SyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncReplaceCatalogAttribute(); + } + + public static void syncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.replaceCatalogAttribute(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_replacecatalogattribute_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java new file mode 100644 index 000000000000..51b78de8b3a4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class AsyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncSetDefaultBranch(); + } + + public static void asyncSetDefaultBranch() throws Exception { + // 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 future = catalogServiceClient.setDefaultBranchCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java new file mode 100644 index 000000000000..f8bf628b4797 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranch(); + } + + public static void syncSetDefaultBranch() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java new file mode 100644 index 000000000000..ea4642d60256 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchCatalogname(); + } + + public static void syncSetDefaultBranchCatalogname() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java new file mode 100644 index 000000000000..0d4394f1afc5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchString(); + } + + public static void syncSetDefaultBranchString() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_setdefaultbranch_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java new file mode 100644 index 000000000000..c978d53b9630 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateAttributesConfig(); + } + + public static void asyncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java new file mode 100644 index 000000000000..cafd9362dd30 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfig(); + } + + public static void syncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.updateAttributesConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java new file mode 100644 index 000000000000..3e7c88806e61 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] +import com.google.cloud.retail.v2alpha.AttributesConfig; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfigAttributesconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfigAttributesconfigFieldmask(); + } + + public static void syncUpdateAttributesConfigAttributesconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfig attributesConfig = AttributesConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + AttributesConfig response = + catalogServiceClient.updateAttributesConfig(attributesConfig, updateMask); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java new file mode 100644 index 000000000000..abd91066c4c8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecatalog_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + asyncUpdateCatalog(); + } + + public static void asyncUpdateCatalog() throws Exception { + // 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 future = catalogServiceClient.updateCatalogCallable().futureCall(request); + // Do something. + Catalog response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecatalog_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..2eb43ab801ba --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecatalog_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java new file mode 100644 index 000000000000..bdf2a7926e7b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] +import com.google.cloud.retail.v2alpha.Catalog; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalogCatalogFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCatalogCatalogFieldmask(); + } + + public static void syncUpdateCatalogCatalogFieldmask() throws Exception { + // 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); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java new file mode 100644 index 000000000000..90bc3b28c643 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateCompletionConfig(); + } + + public static void asyncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java new file mode 100644 index 000000000000..a08484878a01 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfig(); + } + + public static void syncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + CompletionConfig response = catalogServiceClient.updateCompletionConfig(request); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java new file mode 100644 index 000000000000..4b964dc65667 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceClient; +import com.google.cloud.retail.v2alpha.CompletionConfig; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfigCompletionconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfigCompletionconfigFieldmask(); + } + + public static void syncUpdateCompletionConfigCompletionconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfig completionConfig = CompletionConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + CompletionConfig response = + catalogServiceClient.updateCompletionConfig(completionConfig, updateMask); + } + } +} +// [END retail_v2alpha_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..39b253035e1a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_catalogservicesettings_updatecatalog_sync] +import com.google.cloud.retail.v2alpha.CatalogServiceSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_catalogservicesettings_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/AsyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/AsyncCompleteQuery.java new file mode 100644 index 000000000000..78f162b90c46 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/AsyncCompleteQuery.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_completequery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompleteQueryRequest; +import com.google.cloud.retail.v2alpha.CompleteQueryResponse; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import java.util.ArrayList; + +public class AsyncCompleteQuery { + + public static void main(String[] args) throws Exception { + asyncCompleteQuery(); + } + + public static void asyncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + ApiFuture future = + completionServiceClient.completeQueryCallable().futureCall(request); + // Do something. + CompleteQueryResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_completequery_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..aad8166ed62d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/completequery/SyncCompleteQuery.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_completequery_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompleteQueryRequest; +import com.google.cloud.retail.v2alpha.CompleteQueryResponse; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import java.util.ArrayList; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + CompleteQueryResponse response = completionServiceClient.completeQuery(request); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..0cda91366bbc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..ac2af2e90cba --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2alpha_generated_completionserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..7b64939bac13 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2alpha_generated_completionserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java new file mode 100644 index 000000000000..9cc53c727983 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_importcompletiondata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompletionDataInputConfig; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.longrunning.Operation; + +public class AsyncImportCompletionData { + + public static void main(String[] args) throws Exception { + asyncImportCompletionData(); + } + + public static void asyncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + completionServiceClient.importCompletionDataCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_importcompletiondata_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java new file mode 100644 index 000000000000..f13a03ab571b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_importcompletiondata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompletionDataInputConfig; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.cloud.retail.v2alpha.ImportCompletionDataResponse; +import com.google.cloud.retail.v2alpha.ImportMetadata; + +public class AsyncImportCompletionDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportCompletionDataLRO(); + } + + public static void asyncImportCompletionDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + completionServiceClient.importCompletionDataOperationCallable().futureCall(request); + // Do something. + ImportCompletionDataResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_importcompletiondata_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/SyncImportCompletionData.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/SyncImportCompletionData.java new file mode 100644 index 000000000000..580e3c00542d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionserviceclient/importcompletiondata/SyncImportCompletionData.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionserviceclient_importcompletiondata_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CompletionDataInputConfig; +import com.google.cloud.retail.v2alpha.CompletionServiceClient; +import com.google.cloud.retail.v2alpha.ImportCompletionDataRequest; +import com.google.cloud.retail.v2alpha.ImportCompletionDataResponse; + +public class SyncImportCompletionData { + + public static void main(String[] args) throws Exception { + syncImportCompletionData(); + } + + public static void syncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportCompletionDataResponse response = + completionServiceClient.importCompletionDataAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_completionserviceclient_importcompletiondata_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionservicesettings/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionservicesettings/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..a9fca5a675b3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/completionservicesettings/completequery/SyncCompleteQuery.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_completionservicesettings_completequery_sync] +import com.google.cloud.retail.v2alpha.CompletionServiceSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings.Builder completionServiceSettingsBuilder = + CompletionServiceSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceSettings completionServiceSettings = completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_completionservicesettings_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..48ad1aa8c9c0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ControlServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..a214b068af4b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ControlServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2alpha_generated_controlserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..b5ba69f09430 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ControlServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2alpha_generated_controlserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/AsyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/AsyncCreateControl.java new file mode 100644 index 000000000000..7542a5450d0d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/AsyncCreateControl.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.CreateControlRequest; + +public class AsyncCreateControl { + + public static void main(String[] args) throws Exception { + asyncCreateControl(); + } + + public static void asyncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = controlServiceClient.createControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControl.java new file mode 100644 index 000000000000..2a8c5987a588 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControl.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.CreateControlRequest; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + Control response = controlServiceClient.createControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java new file mode 100644 index 000000000000..d19bb2942dea --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncCreateControlCatalognameControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlCatalognameControlString(); + } + + public static void syncCreateControlCatalognameControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java new file mode 100644 index 000000000000..84d88a23fc74 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncCreateControlStringControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlStringControlString(); + } + + public static void syncCreateControlStringControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/AsyncDeleteControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/AsyncDeleteControl.java new file mode 100644 index 000000000000..359a9b5f91d8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/AsyncDeleteControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteControl { + + public static void main(String[] args) throws Exception { + asyncDeleteControl(); + } + + public static void asyncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.deleteControlCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControl.java new file mode 100644 index 000000000000..fccdc58bd9cd --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_sync] +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteControl { + + public static void main(String[] args) throws Exception { + syncDeleteControl(); + } + + public static void syncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + controlServiceClient.deleteControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java new file mode 100644 index 000000000000..36d93eec7927 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_controlname_sync] +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlControlname { + + public static void main(String[] args) throws Exception { + syncDeleteControlControlname(); + } + + public static void syncDeleteControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_controlname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlString.java new file mode 100644 index 000000000000..102964ebf4ef --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/deletecontrol/SyncDeleteControlString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_deletecontrol_string_sync] +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlString { + + public static void main(String[] args) throws Exception { + syncDeleteControlString(); + } + + public static void syncDeleteControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_deletecontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/AsyncGetControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/AsyncGetControl.java new file mode 100644 index 000000000000..1eeec4bfff25 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/AsyncGetControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.GetControlRequest; + +public class AsyncGetControl { + + public static void main(String[] args) throws Exception { + asyncGetControl(); + } + + public static void asyncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.getControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControl.java new file mode 100644 index 000000000000..613195b58904 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.GetControlRequest; + +public class SyncGetControl { + + public static void main(String[] args) throws Exception { + syncGetControl(); + } + + public static void syncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + Control response = controlServiceClient.getControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlControlname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlControlname.java new file mode 100644 index 000000000000..4d38c2b9d475 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlControlname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_controlname_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncGetControlControlname { + + public static void main(String[] args) throws Exception { + syncGetControlControlname(); + } + + public static void syncGetControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_controlname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlString.java new file mode 100644 index 000000000000..105cf04908a1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/getcontrol/SyncGetControlString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_getcontrol_string_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlName; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncGetControlString { + + public static void main(String[] args) throws Exception { + syncGetControlString(); + } + + public static void syncGetControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_getcontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControls.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControls.java new file mode 100644 index 000000000000..590aa457d2fd --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControls.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ListControlsRequest; + +public class AsyncListControls { + + public static void main(String[] args) throws Exception { + asyncListControls(); + } + + public static void asyncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + controlServiceClient.listControlsPagedCallable().futureCall(request); + // Do something. + for (Control element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControlsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControlsPaged.java new file mode 100644 index 000000000000..f418b443292a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/AsyncListControlsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_paged_async] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ListControlsRequest; +import com.google.cloud.retail.v2alpha.ListControlsResponse; +import com.google.common.base.Strings; + +public class AsyncListControlsPaged { + + public static void main(String[] args) throws Exception { + asyncListControlsPaged(); + } + + public static void asyncListControlsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListControlsResponse response = controlServiceClient.listControlsCallable().call(request); + for (Control element : response.getControlsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControls.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControls.java new file mode 100644 index 000000000000..c10195c00ac3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControls.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.ListControlsRequest; + +public class SyncListControls { + + public static void main(String[] args) throws Exception { + syncListControls(); + } + + public static void syncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Control element : controlServiceClient.listControls(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsCatalogname.java new file mode 100644 index 000000000000..3c7d2ac6225a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsCatalogname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncListControlsCatalogname { + + public static void main(String[] args) throws Exception { + syncListControlsCatalogname(); + } + + public static void syncListControlsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsString.java new file mode 100644 index 000000000000..a4f9b72b4b27 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/listcontrols/SyncListControlsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_listcontrols_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; + +public class SyncListControlsString { + + public static void main(String[] args) throws Exception { + syncListControlsString(); + } + + public static void syncListControlsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_listcontrols_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/AsyncUpdateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/AsyncUpdateControl.java new file mode 100644 index 000000000000..d0b62aea0cd6 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/AsyncUpdateControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_updatecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateControl { + + public static void main(String[] args) throws Exception { + asyncUpdateControl(); + } + + public static void asyncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = controlServiceClient.updateControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_updatecontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControl.java new file mode 100644 index 000000000000..18c0ed685ee3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_updatecontrol_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.cloud.retail.v2alpha.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControl { + + public static void main(String[] args) throws Exception { + syncUpdateControl(); + } + + public static void syncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Control response = controlServiceClient.updateControl(request); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_updatecontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java new file mode 100644 index 000000000000..38f4c6ca8292 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] +import com.google.cloud.retail.v2alpha.Control; +import com.google.cloud.retail.v2alpha.ControlServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControlControlFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateControlControlFieldmask(); + } + + public static void syncUpdateControlControlFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + Control control = Control.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Control response = controlServiceClient.updateControl(control, updateMask); + } + } +} +// [END retail_v2alpha_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlservicesettings/createcontrol/SyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlservicesettings/createcontrol/SyncCreateControl.java new file mode 100644 index 000000000000..7101eecce7a7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/controlservicesettings/createcontrol/SyncCreateControl.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_controlservicesettings_createcontrol_sync] +import com.google.cloud.retail.v2alpha.ControlServiceSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings.Builder controlServiceSettingsBuilder = + ControlServiceSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_controlservicesettings_createcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..21f144904bcb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..30bd9e49b902 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2alpha_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..a31180b1bf60 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2alpha_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/AsyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 000000000000..f65f66ab9f16 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/AsyncPredict.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.PredictRequest; +import com.google.cloud.retail.v2alpha.PredictResponse; +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class AsyncPredict { + + public static void main(String[] args) throws Exception { + asyncPredict(); + } + + public static void asyncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_predictionserviceclient_predict_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 000000000000..0db5b88052f2 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionserviceclient/predict/SyncPredict.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionserviceclient_predict_sync] +import com.google.cloud.retail.v2alpha.PredictRequest; +import com.google.cloud.retail.v2alpha.PredictResponse; +import com.google.cloud.retail.v2alpha.PredictionServiceClient; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END retail_v2alpha_generated_predictionserviceclient_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionservicesettings/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 000000000000..92c81f94e224 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/predictionservicesettings/predict/SyncPredict.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_predictionservicesettings_predict_sync] +import com.google.cloud.retail.v2alpha.PredictionServiceSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceSettings predictionServiceSettings = predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_predictionservicesettings_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java new file mode 100644 index 000000000000..ff690b51b760 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlaces(); + } + + public static void asyncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java new file mode 100644 index 000000000000..db3d5a3fd2d2 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlacesLRO(); + } + + public static void asyncAddFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + AddFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java new file mode 100644 index 000000000000..5b78e0518931 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_sync] +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlaces(); + } + + public static void syncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java new file mode 100644 index 000000000000..7f9706f20397 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesProductname(); + } + + public static void syncAddFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java new file mode 100644 index 000000000000..7ca6dd07cb3a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_string_sync] +import com.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesString(); + } + + public static void syncAddFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addfulfillmentplaces_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java new file mode 100644 index 000000000000..ce11cc784e00 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.LocalInventory; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventories(); + } + + public static void asyncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java new file mode 100644 index 000000000000..b05daa80dd6c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.LocalInventory; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventoriesLRO(); + } + + public static void asyncAddLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addLocalInventoriesOperationCallable().futureCall(request); + // Do something. + AddLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventories.java new file mode 100644 index 000000000000..3ebc57299529 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_sync] +import com.google.cloud.retail.v2alpha.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.LocalInventory; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + syncAddLocalInventories(); + } + + public static void syncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java new file mode 100644 index 000000000000..2bc807b4e329 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_productname_sync] +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesProductname(); + } + + public static void syncAddLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java new file mode 100644 index 000000000000..5bf5d2121689 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_addlocalinventories_string_sync] +import com.google.cloud.retail.v2alpha.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncAddLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesString(); + } + + public static void syncAddLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_addlocalinventories_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..baae0b77116d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.ProductServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..ece0b90b7b92 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.ProductServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2alpha_generated_productserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..474b2e351a52 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.ProductServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2alpha_generated_productserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/AsyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 000000000000..a003dfc2837f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/AsyncCreateProduct.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CreateProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class AsyncCreateProduct { + + public static void main(String[] args) throws Exception { + asyncCreateProduct(); + } + + public static void asyncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productServiceClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..bff10c64a8ca --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.CreateProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productServiceClient.createProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java new file mode 100644 index 000000000000..da17e00beead --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_branchnameproductstring_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncCreateProductBranchnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductBranchnameProductString(); + } + + public static void syncCreateProductBranchnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_branchnameproductstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductStringProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 000000000000..c8744a383683 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/createproduct/SyncCreateProductStringProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_createproduct_stringproductstring_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncCreateProductStringProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductStringProductString(); + } + + public static void syncCreateProductStringProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_createproduct_stringproductstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/AsyncDeleteProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 000000000000..c83106ab2c87 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/AsyncDeleteProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.DeleteProductRequest; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteProduct { + + public static void main(String[] args) throws Exception { + asyncDeleteProduct(); + } + + public static void asyncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 000000000000..e804a6cf1580 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_sync] +import com.google.cloud.retail.v2alpha.DeleteProductRequest; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProduct { + + public static void main(String[] args) throws Exception { + syncDeleteProduct(); + } + + public static void syncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + productServiceClient.deleteProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 000000000000..1ef70bb470d4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductProductname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_productname_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProductProductname { + + public static void main(String[] args) throws Exception { + syncDeleteProductProductname(); + } + + public static void syncDeleteProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 000000000000..a0928115b796 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/deleteproduct/SyncDeleteProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_deleteproduct_string_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProductString { + + public static void main(String[] args) throws Exception { + syncDeleteProductString(); + } + + public static void syncDeleteProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_deleteproduct_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/AsyncGetProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/AsyncGetProduct.java new file mode 100644 index 000000000000..78d6ec83fb0b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/AsyncGetProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.GetProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class AsyncGetProduct { + + public static void main(String[] args) throws Exception { + asyncGetProduct(); + } + + public static void asyncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProduct.java new file mode 100644 index 000000000000..adeba2d36a57 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_sync] +import com.google.cloud.retail.v2alpha.GetProductRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncGetProduct { + + public static void main(String[] args) throws Exception { + syncGetProduct(); + } + + public static void syncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + Product response = productServiceClient.getProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 000000000000..ccf07b4eac72 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductProductname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_productname_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncGetProductProductname { + + public static void main(String[] args) throws Exception { + syncGetProductProductname(); + } + + public static void syncGetProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductString.java new file mode 100644 index 000000000000..dba9f9288c5e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/getproduct/SyncGetProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_getproduct_string_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncGetProductString { + + public static void main(String[] args) throws Exception { + syncGetProductString(); + } + + public static void syncGetProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_getproduct_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProducts.java new file mode 100644 index 000000000000..ba69ccfc0c20 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_importproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ProductInputConfig; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncImportProducts { + + public static void main(String[] args) throws Exception { + asyncImportProducts(); + } + + public static void asyncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + productServiceClient.importProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_importproducts_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProductsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProductsLRO.java new file mode 100644 index 000000000000..15032ed92979 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/AsyncImportProductsLRO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_importproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ImportProductsResponse; +import com.google.cloud.retail.v2alpha.ProductInputConfig; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncImportProductsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductsLRO(); + } + + public static void asyncImportProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + productServiceClient.importProductsOperationCallable().futureCall(request); + // Do something. + ImportProductsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_importproducts_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/SyncImportProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/SyncImportProducts.java new file mode 100644 index 000000000000..7717ec99386a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/importproducts/SyncImportProducts.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_importproducts_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportProductsRequest; +import com.google.cloud.retail.v2alpha.ImportProductsResponse; +import com.google.cloud.retail.v2alpha.ProductInputConfig; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncImportProducts { + + public static void main(String[] args) throws Exception { + syncImportProducts(); + } + + public static void syncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportProductsResponse response = productServiceClient.importProductsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_importproducts_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProducts.java new file mode 100644 index 000000000000..0f6dd1aa794a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncListProducts { + + public static void main(String[] args) throws Exception { + asyncListProducts(); + } + + public static void asyncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .setRequireTotalSize(true) + .build(); + ApiFuture future = + productServiceClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProductsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 000000000000..b31036526dde --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,63 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_paged_async] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.ListProductsResponse; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +public class AsyncListProductsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsPaged(); + } + + public static void asyncListProductsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .setRequireTotalSize(true) + .build(); + while (true) { + ListProductsResponse response = productServiceClient.listProductsCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProducts.java new file mode 100644 index 000000000000..ea47a194414c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProducts.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ListProductsRequest; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncListProducts { + + public static void main(String[] args) throws Exception { + syncListProducts(); + } + + public static void syncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .setRequireTotalSize(true) + .build(); + for (Product element : productServiceClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsBranchname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsBranchname.java new file mode 100644 index 000000000000..c86613f9463f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsBranchname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_branchname_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncListProductsBranchname { + + public static void main(String[] args) throws Exception { + syncListProductsBranchname(); + } + + public static void syncListProductsBranchname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_branchname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsString.java new file mode 100644 index 000000000000..5cc1f3818e6a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/listproducts/SyncListProductsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_listproducts_string_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; + +public class SyncListProductsString { + + public static void main(String[] args) throws Exception { + syncListProductsString(); + } + + public static void syncListProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_productserviceclient_listproducts_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProducts.java new file mode 100644 index 000000000000..c11152387c00 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProducts.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_purgeproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.PurgeProductsRequest; +import com.google.longrunning.Operation; + +public class AsyncPurgeProducts { + + public static void main(String[] args) throws Exception { + asyncPurgeProducts(); + } + + public static void asyncPurgeProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + productServiceClient.purgeProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_purgeproducts_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProductsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProductsLRO.java new file mode 100644 index 000000000000..8c3b47738910 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/AsyncPurgeProductsLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_purgeproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.PurgeProductsMetadata; +import com.google.cloud.retail.v2alpha.PurgeProductsRequest; +import com.google.cloud.retail.v2alpha.PurgeProductsResponse; + +public class AsyncPurgeProductsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeProductsLRO(); + } + + public static void asyncPurgeProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + productServiceClient.purgeProductsOperationCallable().futureCall(request); + // Do something. + PurgeProductsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_purgeproducts_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/SyncPurgeProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/SyncPurgeProducts.java new file mode 100644 index 000000000000..3cf1fa1a5f4e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/purgeproducts/SyncPurgeProducts.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_purgeproducts_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.PurgeProductsRequest; +import com.google.cloud.retail.v2alpha.PurgeProductsResponse; + +public class SyncPurgeProducts { + + public static void main(String[] args) throws Exception { + syncPurgeProducts(); + } + + public static void syncPurgeProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + PurgeProductsRequest request = + PurgeProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeProductsResponse response = productServiceClient.purgeProductsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_purgeproducts_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java new file mode 100644 index 000000000000..18191943e8f5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlaces(); + } + + public static void asyncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java new file mode 100644 index 000000000000..4b96f9e0b47e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlacesLRO(); + } + + public static void asyncRemoveFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + RemoveFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java new file mode 100644 index 000000000000..849b2750fb8c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlaces(); + } + + public static void syncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java new file mode 100644 index 000000000000..bfa7820f32fe --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesProductname(); + } + + public static void syncRemoveFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java new file mode 100644 index 000000000000..f919d3706dd8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_string_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesString(); + } + + public static void syncRemoveFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removefulfillmentplaces_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java new file mode 100644 index 000000000000..1a36ee4e2d15 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventories(); + } + + public static void asyncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java new file mode 100644 index 000000000000..8c3890388233 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventoriesLRO(); + } + + public static void asyncRemoveLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeLocalInventoriesOperationCallable().futureCall(request); + // Do something. + RemoveLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java new file mode 100644 index 000000000000..58d625bb67d8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventories(); + } + + public static void syncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java new file mode 100644 index 000000000000..8c496a925281 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_productname_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesProductname(); + } + + public static void syncRemoveLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java new file mode 100644 index 000000000000..bc46b4944c86 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_removelocalinventories_string_sync] +import com.google.cloud.retail.v2alpha.ProductName; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesString(); + } + + public static void syncRemoveLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_removelocalinventories_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventory.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventory.java new file mode 100644 index 000000000000..19020c793f78 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventory.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventory { + + public static void main(String[] args) throws Exception { + asyncSetInventory(); + } + + public static void asyncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.setInventoryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventoryLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventoryLRO.java new file mode 100644 index 000000000000..9e579b19286a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/AsyncSetInventoryLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryMetadata; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventoryLRO { + + public static void main(String[] args) throws Exception { + asyncSetInventoryLRO(); + } + + public static void asyncSetInventoryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.setInventoryOperationCallable().futureCall(request); + // Do something. + SetInventoryResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventory.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventory.java new file mode 100644 index 000000000000..b30889442963 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventory.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryRequest; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncSetInventory { + + public static void main(String[] args) throws Exception { + syncSetInventory(); + } + + public static void syncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + SetInventoryResponse response = productServiceClient.setInventoryAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java new file mode 100644 index 000000000000..1e668c88920c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_setinventory_productfieldmask_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.SetInventoryResponse; +import com.google.protobuf.FieldMask; + +public class SyncSetInventoryProductFieldmask { + + public static void main(String[] args) throws Exception { + syncSetInventoryProductFieldmask(); + } + + public static void syncSetInventoryProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product inventory = Product.newBuilder().build(); + FieldMask setMask = FieldMask.newBuilder().build(); + SetInventoryResponse response = + productServiceClient.setInventoryAsync(inventory, setMask).get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_setinventory_productfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/AsyncUpdateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 000000000000..cdb496860f44 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/AsyncUpdateProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProduct { + + public static void main(String[] args) throws Exception { + asyncUpdateProduct(); + } + + public static void asyncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_updateproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 000000000000..a8bdaa837144 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_updateproduct_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.cloud.retail.v2alpha.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProduct { + + public static void main(String[] args) throws Exception { + syncUpdateProduct(); + } + + public static void syncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + Product response = productServiceClient.updateProduct(request); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_updateproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 000000000000..2f65a2a05e7e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productserviceclient_updateproduct_productfieldmask_sync] +import com.google.cloud.retail.v2alpha.Product; +import com.google.cloud.retail.v2alpha.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductProductFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductProductFieldmask(); + } + + public static void syncUpdateProductProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productServiceClient.updateProduct(product, updateMask); + } + } +} +// [END retail_v2alpha_generated_productserviceclient_updateproduct_productfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productservicesettings/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productservicesettings/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..5a1e4aee92b3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/productservicesettings/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_productservicesettings_createproduct_sync] +import com.google.cloud.retail.v2alpha.ProductServiceSettings; +import java.time.Duration; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings.Builder productServiceSettingsBuilder = + ProductServiceSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_productservicesettings_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..86db952947b1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.SearchServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..10124f5b4d3a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.SearchServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2alpha_generated_searchserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..769ee252df96 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.SearchServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2alpha_generated_searchserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearch.java new file mode 100644 index 000000000000..7792d93f774f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearch.java @@ -0,0 +1,69 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_search_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.UserInfo; +import java.util.ArrayList; + +public class AsyncSearch { + + public static void main(String[] args) throws Exception { + asyncSearch(); + } + + public static void asyncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + ApiFuture future = + searchServiceClient.searchPagedCallable().futureCall(request); + // Do something. + for (SearchResponse.SearchResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_searchserviceclient_search_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearchPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearchPaged.java new file mode 100644 index 000000000000..a5666a8408fc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/AsyncSearchPaged.java @@ -0,0 +1,75 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_search_paged_async] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.UserInfo; +import com.google.common.base.Strings; +import java.util.ArrayList; + +public class AsyncSearchPaged { + + public static void main(String[] args) throws Exception { + asyncSearchPaged(); + } + + public static void asyncSearchPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + while (true) { + SearchResponse response = searchServiceClient.searchCallable().call(request); + for (SearchResponse.SearchResult element : response.getResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_searchserviceclient_search_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/SyncSearch.java new file mode 100644 index 000000000000..38878c99e19a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchserviceclient/search/SyncSearch.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchserviceclient_search_sync] +import com.google.cloud.retail.v2alpha.BranchName; +import com.google.cloud.retail.v2alpha.SearchRequest; +import com.google.cloud.retail.v2alpha.SearchResponse; +import com.google.cloud.retail.v2alpha.SearchServiceClient; +import com.google.cloud.retail.v2alpha.UserInfo; +import java.util.ArrayList; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_searchserviceclient_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchservicesettings/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchservicesettings/search/SyncSearch.java new file mode 100644 index 000000000000..e0294354b911 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/searchservicesettings/search/SyncSearch.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_searchservicesettings_search_sync] +import com.google.cloud.retail.v2alpha.SearchServiceSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings.Builder searchServiceSettingsBuilder = SearchServiceSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_searchservicesettings_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/AsyncAddControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/AsyncAddControl.java new file mode 100644 index 000000000000..992e638d386e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/AsyncAddControl.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.AddControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncAddControl { + + public static void main(String[] args) throws Exception { + asyncAddControl(); + } + + public static void asyncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.addControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControl.java new file mode 100644 index 000000000000..a453f1d1649f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_sync] +import com.google.cloud.retail.v2alpha.AddControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncAddControl { + + public static void main(String[] args) throws Exception { + syncAddControl(); + } + + public static void syncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.addControl(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java new file mode 100644 index 000000000000..3088886b7706 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncAddControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncAddControlServingconfigname(); + } + + public static void syncAddControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlString.java new file mode 100644 index 000000000000..c7b15a7c3ac7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/addcontrol/SyncAddControlString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_addcontrol_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncAddControlString { + + public static void main(String[] args) throws Exception { + syncAddControlString(); + } + + public static void syncAddControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_addcontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..a9a7f8ba5b1c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..15d508accbf3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..5733aa8f3a17 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java new file mode 100644 index 000000000000..2d3ac99e4ff9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CreateServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + asyncCreateServingConfig(); + } + + public static void asyncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ApiFuture future = + servingConfigServiceClient.createServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 000000000000..89219d883811 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.CreateServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ServingConfig response = servingConfigServiceClient.createServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java new file mode 100644 index 000000000000..c2f5a387a9ae --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncCreateServingConfigCatalognameServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigCatalognameServingconfigString(); + } + + public static void syncCreateServingConfigCatalognameServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java new file mode 100644 index 000000000000..07956f54fc20 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncCreateServingConfigStringServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigStringServingconfigString(); + } + + public static void syncCreateServingConfigStringServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java new file mode 100644 index 000000000000..4d982b38c643 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.DeleteServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteServingConfig(); + } + + public static void asyncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.deleteServingConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java new file mode 100644 index 000000000000..2604f10a43c5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_sync] +import com.google.cloud.retail.v2alpha.DeleteServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfig(); + } + + public static void syncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + servingConfigServiceClient.deleteServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java new file mode 100644 index 000000000000..dcee76a7f776 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigServingconfigname(); + } + + public static void syncDeleteServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java new file mode 100644 index 000000000000..514434265730 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigString(); + } + + public static void syncDeleteServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_deleteservingconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java new file mode 100644 index 000000000000..1e6ad4a141ac --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.GetServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncGetServingConfig { + + public static void main(String[] args) throws Exception { + asyncGetServingConfig(); + } + + public static void asyncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.getServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java new file mode 100644 index 000000000000..eecb25e0a4ff --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_sync] +import com.google.cloud.retail.v2alpha.GetServingConfigRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncGetServingConfig { + + public static void main(String[] args) throws Exception { + syncGetServingConfig(); + } + + public static void syncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ServingConfig response = servingConfigServiceClient.getServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java new file mode 100644 index 000000000000..5740b8b8d9b4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncGetServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncGetServingConfigServingconfigname(); + } + + public static void syncGetServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java new file mode 100644 index 000000000000..1d90a5a8308f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncGetServingConfigString { + + public static void main(String[] args) throws Exception { + syncGetServingConfigString(); + } + + public static void syncGetServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_getservingconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java new file mode 100644 index 000000000000..0752655cfdeb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncListServingConfigs { + + public static void main(String[] args) throws Exception { + asyncListServingConfigs(); + } + + public static void asyncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + servingConfigServiceClient.listServingConfigsPagedCallable().futureCall(request); + // Do something. + for (ServingConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java new file mode 100644 index 000000000000..18de65674da5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_paged_async] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ListServingConfigsResponse; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.common.base.Strings; + +public class AsyncListServingConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListServingConfigsPaged(); + } + + public static void asyncListServingConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListServingConfigsResponse response = + servingConfigServiceClient.listServingConfigsCallable().call(request); + for (ServingConfig element : response.getServingConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java new file mode 100644 index 000000000000..06072f40fea4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ListServingConfigsRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncListServingConfigs { + + public static void main(String[] args) throws Exception { + syncListServingConfigs(); + } + + public static void syncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java new file mode 100644 index 000000000000..d812272eb054 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncListServingConfigsCatalogname { + + public static void main(String[] args) throws Exception { + syncListServingConfigsCatalogname(); + } + + public static void syncListServingConfigsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java new file mode 100644 index 000000000000..732ec149e6e5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_string_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncListServingConfigsString { + + public static void main(String[] args) throws Exception { + syncListServingConfigsString(); + } + + public static void syncListServingConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_listservingconfigs_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java new file mode 100644 index 000000000000..c9b6ba344e10 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.RemoveControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class AsyncRemoveControl { + + public static void main(String[] args) throws Exception { + asyncRemoveControl(); + } + + public static void asyncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.removeControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControl.java new file mode 100644 index 000000000000..f9c96d5551d5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_sync] +import com.google.cloud.retail.v2alpha.RemoveControlRequest; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncRemoveControl { + + public static void main(String[] args) throws Exception { + syncRemoveControl(); + } + + public static void syncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.removeControl(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java new file mode 100644 index 000000000000..df8b8962d4b8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncRemoveControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncRemoveControlServingconfigname(); + } + + public static void syncRemoveControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java new file mode 100644 index 000000000000..9a293d67eb71 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_removecontrol_string_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigName; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; + +public class SyncRemoveControlString { + + public static void main(String[] args) throws Exception { + syncRemoveControlString(); + } + + public static void syncRemoveControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_removecontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java new file mode 100644 index 000000000000..6d1efdaa5e71 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateServingConfig(); + } + + public static void asyncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + servingConfigServiceClient.updateServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java new file mode 100644 index 000000000000..b8e568a5ab16 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.cloud.retail.v2alpha.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfig(); + } + + public static void syncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ServingConfig response = servingConfigServiceClient.updateServingConfig(request); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java new file mode 100644 index 000000000000..0da7a95efc2c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] +import com.google.cloud.retail.v2alpha.ServingConfig; +import com.google.cloud.retail.v2alpha.ServingConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfigServingconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfigServingconfigFieldmask(); + } + + public static void syncUpdateServingConfigServingconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ServingConfig response = + servingConfigServiceClient.updateServingConfig(servingConfig, updateMask); + } + } +} +// [END retail_v2alpha_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 000000000000..68512e7b86db --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_servingconfigservicesettings_createservingconfig_sync] +import com.google.cloud.retail.v2alpha.ServingConfigServiceSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_servingconfigservicesettings_createservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..5133c288391d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_catalogservicestubsettings_updatecatalog_sync] +import com.google.cloud.retail.v2alpha.stub.CatalogServiceStubSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceStubSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceStubSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceStubSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_catalogservicestubsettings_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..9ca8930be53d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_completionservicestubsettings_completequery_sync] +import com.google.cloud.retail.v2alpha.stub.CompletionServiceStubSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceStubSettings.Builder completionServiceSettingsBuilder = + CompletionServiceStubSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceStubSettings completionServiceSettings = + completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_completionservicestubsettings_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java new file mode 100644 index 000000000000..f4c4c7fe24f2 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_controlservicestubsettings_createcontrol_sync] +import com.google.cloud.retail.v2alpha.stub.ControlServiceStubSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceStubSettings.Builder controlServiceSettingsBuilder = + ControlServiceStubSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceStubSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_controlservicestubsettings_createcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/predictionservicestubsettings/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 000000000000..890b642bb24c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/predictionservicestubsettings/predict/SyncPredict.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.retail.v2alpha.stub.PredictionServiceStubSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceStubSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceStubSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceStubSettings predictionServiceSettings = + predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_predictionservicestubsettings_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/productservicestubsettings/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/productservicestubsettings/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..4a3bc6f04d41 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/productservicestubsettings/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_productservicestubsettings_createproduct_sync] +import com.google.cloud.retail.v2alpha.stub.ProductServiceStubSettings; +import java.time.Duration; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceStubSettings.Builder productServiceSettingsBuilder = + ProductServiceStubSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceStubSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_productservicestubsettings_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/searchservicestubsettings/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/searchservicestubsettings/search/SyncSearch.java new file mode 100644 index 000000000000..8ed8a423752a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/searchservicestubsettings/search/SyncSearch.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_searchservicestubsettings_search_sync] +import com.google.cloud.retail.v2alpha.stub.SearchServiceStubSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceStubSettings.Builder searchServiceSettingsBuilder = + SearchServiceStubSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceStubSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_searchservicestubsettings_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 000000000000..f2b8880a162d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_servingconfigservicestubsettings_createservingconfig_sync] +import com.google.cloud.retail.v2alpha.stub.ServingConfigServiceStubSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceStubSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceStubSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceStubSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_servingconfigservicestubsettings_createservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..8da2f0255551 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.stub.samples; + +// [START retail_v2alpha_generated_usereventservicestubsettings_writeuserevent_sync] +import com.google.cloud.retail.v2alpha.stub.UserEventServiceStubSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceStubSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceStubSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceStubSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_usereventservicestubsettings_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java new file mode 100644 index 000000000000..5ade671c131a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_collectuserevent_async] +import com.google.api.HttpBody; +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CollectUserEventRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + asyncCollectUserEvent(); + } + + public static void asyncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + ApiFuture future = + userEventServiceClient.collectUserEventCallable().futureCall(request); + // Do something. + HttpBody response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_collectuserevent_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java new file mode 100644 index 000000000000..1160686106c5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_collectuserevent_sync] +import com.google.api.HttpBody; +import com.google.cloud.retail.v2alpha.CollectUserEventRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + syncCollectUserEvent(); + } + + public static void syncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + HttpBody response = userEventServiceClient.collectUserEvent(request); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_collectuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..183e14bfe699 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; +import com.google.cloud.retail.v2alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..c9839dd3dc08 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2alpha_generated_usereventserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..dea987d9a0f2 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; +import com.google.cloud.retail.v2alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2alpha_generated_usereventserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEvents.java new file mode 100644 index 000000000000..a028e74b5264 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEvents.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_importuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.UserEventInputConfig; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncImportUserEvents { + + public static void main(String[] args) throws Exception { + asyncImportUserEvents(); + } + + public static void asyncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.importUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_importuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java new file mode 100644 index 000000000000..4bd04e5aa3ae --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_importuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportMetadata; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.ImportUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventInputConfig; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncImportUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncImportUserEventsLRO(); + } + + public static void asyncImportUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + OperationFuture future = + userEventServiceClient.importUserEventsOperationCallable().futureCall(request); + // Do something. + ImportUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_importuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/SyncImportUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/SyncImportUserEvents.java new file mode 100644 index 000000000000..28f8f78d4dcf --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/importuserevents/SyncImportUserEvents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_importuserevents_sync] +import com.google.cloud.retail.v2alpha.CatalogName; +import com.google.cloud.retail.v2alpha.ImportErrorsConfig; +import com.google.cloud.retail.v2alpha.ImportUserEventsRequest; +import com.google.cloud.retail.v2alpha.ImportUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventInputConfig; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncImportUserEvents { + + public static void main(String[] args) throws Exception { + syncImportUserEvents(); + } + + public static void syncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ImportUserEventsResponse response = + userEventServiceClient.importUserEventsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_importuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java new file mode 100644 index 000000000000..1f9badbbc6c0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_purgeuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEvents(); + } + + public static void asyncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + userEventServiceClient.purgeUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_purgeuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java new file mode 100644 index 000000000000..74cdb4bd9fa6 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_purgeuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.PurgeMetadata; +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.PurgeUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncPurgeUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEventsLRO(); + } + + public static void asyncPurgeUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + userEventServiceClient.purgeUserEventsOperationCallable().futureCall(request); + // Do something. + PurgeUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_purgeuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java new file mode 100644 index 000000000000..f2cba1ffef5d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_purgeuserevents_sync] +import com.google.cloud.retail.v2alpha.PurgeUserEventsRequest; +import com.google.cloud.retail.v2alpha.PurgeUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + syncPurgeUserEvents(); + } + + public static void syncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeUserEventsResponse response = userEventServiceClient.purgeUserEventsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_purgeuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java new file mode 100644 index 000000000000..39f60ef83b41 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEvents(); + } + + public static void asyncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + ApiFuture future = + userEventServiceClient.rejoinUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java new file mode 100644 index 000000000000..094dcc4daa6b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2alpha.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.RejoinUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class AsyncRejoinUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEventsLRO(); + } + + public static void asyncRejoinUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + OperationFuture future = + userEventServiceClient.rejoinUserEventsOperationCallable().futureCall(request); + // Do something. + RejoinUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java new file mode 100644 index 000000000000..77cffbb650e6 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_sync] +import com.google.cloud.retail.v2alpha.RejoinUserEventsRequest; +import com.google.cloud.retail.v2alpha.RejoinUserEventsResponse; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; + +public class SyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + syncRejoinUserEvents(); + } + + public static void syncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + RejoinUserEventsResponse response = + userEventServiceClient.rejoinUserEventsAsync(request).get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_rejoinuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java new file mode 100644 index 000000000000..76b3c78a7075 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_writeuserevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.WriteUserEventRequest; + +public class AsyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + asyncWriteUserEvent(); + } + + public static void asyncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.writeUserEventCallable().futureCall(request); + // Do something. + UserEvent response = future.get(); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_writeuserevent_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..c9690fc34678 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventserviceclient_writeuserevent_sync] +import com.google.cloud.retail.v2alpha.UserEvent; +import com.google.cloud.retail.v2alpha.UserEventServiceClient; +import com.google.cloud.retail.v2alpha.WriteUserEventRequest; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + UserEvent response = userEventServiceClient.writeUserEvent(request); + } + } +} +// [END retail_v2alpha_generated_usereventserviceclient_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..21d761d186a7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2alpha/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2alpha.samples; + +// [START retail_v2alpha_generated_usereventservicesettings_writeuserevent_sync] +import com.google.cloud.retail.v2alpha.UserEventServiceSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2alpha_generated_usereventservicesettings_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java new file mode 100644 index 000000000000..84ac3536830f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/AsyncAddCatalogAttribute.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_addcatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class AsyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncAddCatalogAttribute(); + } + + public static void asyncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.addCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_addcatalogattribute_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java new file mode 100644 index 000000000000..95b7db634efb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/addcatalogattribute/SyncAddCatalogAttribute.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_addcatalogattribute_sync] +import com.google.cloud.retail.v2beta.AddCatalogAttributeRequest; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class SyncAddCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncAddCatalogAttribute(); + } + + public static void syncAddCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AddCatalogAttributeRequest request = + AddCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.addCatalogAttribute(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_addcatalogattribute_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..e11bb764a9e9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CatalogServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // 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); + } +} +// [END retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..5302d33d46f7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CatalogServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings catalogServiceSettings = + CatalogServiceSettings.newBuilder() + .setTransportChannelProvider( + CatalogServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CatalogServiceClient catalogServiceClient = CatalogServiceClient.create(catalogServiceSettings); + } +} +// [END retail_v2beta_generated_catalogserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..f7077726efc5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CatalogServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // 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); + } +} +// [END retail_v2beta_generated_catalogserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java new file mode 100644 index 000000000000..3fe2b04feb4e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/AsyncGetAttributesConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetAttributesConfigRequest; + +public class AsyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncGetAttributesConfig(); + } + + public static void asyncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java new file mode 100644 index 000000000000..f9fbcc7b9aeb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetAttributesConfigRequest; + +public class SyncGetAttributesConfig { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfig(); + } + + public static void syncGetAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetAttributesConfigRequest request = + GetAttributesConfigRequest.newBuilder() + .setName(AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java new file mode 100644 index 000000000000..4ae60e579993 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigAttributesconfigname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class SyncGetAttributesConfigAttributesconfigname { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigAttributesconfigname(); + } + + public static void syncGetAttributesConfigAttributesconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfigName name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_attributesconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java new file mode 100644 index 000000000000..186e4186ac4a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getattributesconfig/SyncGetAttributesConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getattributesconfig_string_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; + +public class SyncGetAttributesConfigString { + + public static void main(String[] args) throws Exception { + syncGetAttributesConfigString(); + } + + public static void syncGetAttributesConfigString() throws Exception { + // 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 name = AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + AttributesConfig response = catalogServiceClient.getAttributesConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getattributesconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java new file mode 100644 index 000000000000..1b76379f191d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/AsyncGetCompletionConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; +import com.google.cloud.retail.v2beta.GetCompletionConfigRequest; + +public class AsyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncGetCompletionConfig(); + } + + public static void asyncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + ApiFuture future = + catalogServiceClient.getCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java new file mode 100644 index 000000000000..82639a1e04a2 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; +import com.google.cloud.retail.v2beta.GetCompletionConfigRequest; + +public class SyncGetCompletionConfig { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfig(); + } + + public static void syncGetCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + GetCompletionConfigRequest request = + GetCompletionConfigRequest.newBuilder() + .setName(CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .build(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java new file mode 100644 index 000000000000..8ee48946ee3b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigCompletionconfigname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; + +public class SyncGetCompletionConfigCompletionconfigname { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigCompletionconfigname(); + } + + public static void syncGetCompletionConfigCompletionconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfigName name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_completionconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java new file mode 100644 index 000000000000..a09242daf5f3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getcompletionconfig/SyncGetCompletionConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getcompletionconfig_string_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.CompletionConfigName; + +public class SyncGetCompletionConfigString { + + public static void main(String[] args) throws Exception { + syncGetCompletionConfigString(); + } + + public static void syncGetCompletionConfigString() throws Exception { + // 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 name = CompletionConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + CompletionConfig response = catalogServiceClient.getCompletionConfig(name); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getcompletionconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java new file mode 100644 index 000000000000..ca136476566a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/AsyncGetDefaultBranch.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class AsyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncGetDefaultBranch(); + } + + public static void asyncGetDefaultBranch() throws Exception { + // 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 future = + catalogServiceClient.getDefaultBranchCallable().futureCall(request); + // Do something. + GetDefaultBranchResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java new file mode 100644 index 000000000000..33edc3abed05 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranch.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchRequest; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class SyncGetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranch(); + } + + public static void syncGetDefaultBranch() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java new file mode 100644 index 000000000000..335ea14be238 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchCatalogname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchCatalogname(); + } + + public static void syncGetDefaultBranchCatalogname() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java new file mode 100644 index 000000000000..81bef11f6e00 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/getdefaultbranch/SyncGetDefaultBranchString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_getdefaultbranch_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.GetDefaultBranchResponse; + +public class SyncGetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncGetDefaultBranchString(); + } + + public static void syncGetDefaultBranchString() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_getdefaultbranch_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogs.java new file mode 100644 index 000000000000..ababcfd9349c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.LocationName; + +public class AsyncListCatalogs { + + public static void main(String[] args) throws Exception { + asyncListCatalogs(); + } + + public static void asyncListCatalogs() throws Exception { + // 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 future = + catalogServiceClient.listCatalogsPagedCallable().futureCall(request); + // Do something. + for (Catalog element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java new file mode 100644 index 000000000000..7679cd51a811 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/AsyncListCatalogsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_paged_async] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.ListCatalogsResponse; +import com.google.cloud.retail.v2beta.LocationName; +import com.google.common.base.Strings; + +public class AsyncListCatalogsPaged { + + public static void main(String[] args) throws Exception { + asyncListCatalogsPaged(); + } + + public static void asyncListCatalogsPaged() throws Exception { + // 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.getCatalogsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogs.java new file mode 100644 index 000000000000..7c30dedfb36e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogs.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ListCatalogsRequest; +import com.google.cloud.retail.v2beta.LocationName; + +public class SyncListCatalogs { + + public static void main(String[] args) throws Exception { + syncListCatalogs(); + } + + public static void syncListCatalogs() throws Exception { + // 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); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java new file mode 100644 index 000000000000..8ea17f20484c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_locationname_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.LocationName; + +public class SyncListCatalogsLocationname { + + public static void main(String[] args) throws Exception { + syncListCatalogsLocationname(); + } + + public static void syncListCatalogsLocationname() throws Exception { + // 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); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_locationname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsString.java new file mode 100644 index 000000000000..89c0e5fccfe8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/listcatalogs/SyncListCatalogsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_listcatalogs_string_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.LocationName; + +public class SyncListCatalogsString { + + public static void main(String[] args) throws Exception { + syncListCatalogsString(); + } + + public static void syncListCatalogsString() throws Exception { + // 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); + } + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_listcatalogs_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java new file mode 100644 index 000000000000..03d463cfa7c4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/AsyncRemoveCatalogAttribute.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_removecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + +public class AsyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncRemoveCatalogAttribute(); + } + + public static void asyncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + ApiFuture future = + catalogServiceClient.removeCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_removecatalogattribute_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java new file mode 100644 index 000000000000..894ab601cf24 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/removecatalogattribute/SyncRemoveCatalogAttribute.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_removecatalogattribute_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + +public class SyncRemoveCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncRemoveCatalogAttribute(); + } + + public static void syncRemoveCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + RemoveCatalogAttributeRequest request = + RemoveCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setKey("key106079") + .build(); + AttributesConfig response = catalogServiceClient.removeCatalogAttribute(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_removecatalogattribute_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java new file mode 100644 index 000000000000..02f62a5f0cb5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/AsyncReplaceCatalogAttribute.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + asyncReplaceCatalogAttribute(); + } + + public static void asyncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.replaceCatalogAttributeCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java new file mode 100644 index 000000000000..ffe7f21522a8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/replacecatalogattribute/SyncReplaceCatalogAttribute.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.AttributesConfigName; +import com.google.cloud.retail.v2beta.CatalogAttribute; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; +import com.google.protobuf.FieldMask; + +public class SyncReplaceCatalogAttribute { + + public static void main(String[] args) throws Exception { + syncReplaceCatalogAttribute(); + } + + public static void syncReplaceCatalogAttribute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + ReplaceCatalogAttributeRequest request = + ReplaceCatalogAttributeRequest.newBuilder() + .setAttributesConfig( + AttributesConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setCatalogAttribute(CatalogAttribute.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.replaceCatalogAttribute(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_replacecatalogattribute_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java new file mode 100644 index 000000000000..88af8fe63a2e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/AsyncSetDefaultBranch.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class AsyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + asyncSetDefaultBranch(); + } + + public static void asyncSetDefaultBranch() throws Exception { + // 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 future = catalogServiceClient.setDefaultBranchCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java new file mode 100644 index 000000000000..f860546869e3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranch.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.SetDefaultBranchRequest; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranch { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranch(); + } + + public static void syncSetDefaultBranch() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java new file mode 100644 index 000000000000..f7707632e7d0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchCatalogname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchCatalogname { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchCatalogname(); + } + + public static void syncSetDefaultBranchCatalogname() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java new file mode 100644 index 000000000000..88f9d27fa865 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/setdefaultbranch/SyncSetDefaultBranchString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_setdefaultbranch_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.Empty; + +public class SyncSetDefaultBranchString { + + public static void main(String[] args) throws Exception { + syncSetDefaultBranchString(); + } + + public static void syncSetDefaultBranchString() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_setdefaultbranch_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java new file mode 100644 index 000000000000..434560269d0e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/AsyncUpdateAttributesConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updateattributesconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateAttributesConfig(); + } + + public static void asyncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateAttributesConfigCallable().futureCall(request); + // Do something. + AttributesConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updateattributesconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java new file mode 100644 index 000000000000..abbf7b88d451 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updateattributesconfig_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateAttributesConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfig { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfig(); + } + + public static void syncUpdateAttributesConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateAttributesConfigRequest request = + UpdateAttributesConfigRequest.newBuilder() + .setAttributesConfig(AttributesConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AttributesConfig response = catalogServiceClient.updateAttributesConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updateattributesconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java new file mode 100644 index 000000000000..cab614a3129c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updateattributesconfig/SyncUpdateAttributesConfigAttributesconfigFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] +import com.google.cloud.retail.v2beta.AttributesConfig; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAttributesConfigAttributesconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateAttributesConfigAttributesconfigFieldmask(); + } + + public static void syncUpdateAttributesConfigAttributesconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + AttributesConfig attributesConfig = AttributesConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + AttributesConfig response = + catalogServiceClient.updateAttributesConfig(attributesConfig, updateMask); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updateattributesconfig_attributesconfigfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java new file mode 100644 index 000000000000..260cf62c2919 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/AsyncUpdateCatalog.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecatalog_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + asyncUpdateCatalog(); + } + + public static void asyncUpdateCatalog() throws Exception { + // 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 future = catalogServiceClient.updateCatalogCallable().futureCall(request); + // Do something. + Catalog response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecatalog_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..c2a33974fa99 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecatalog_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.UpdateCatalogRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java new file mode 100644 index 000000000000..ff243649f3b8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecatalog/SyncUpdateCatalogCatalogFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] +import com.google.cloud.retail.v2beta.Catalog; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCatalogCatalogFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCatalogCatalogFieldmask(); + } + + public static void syncUpdateCatalogCatalogFieldmask() throws Exception { + // 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); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecatalog_catalogfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java new file mode 100644 index 000000000000..f2d4a9742454 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/AsyncUpdateCompletionConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateCompletionConfig(); + } + + public static void asyncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + catalogServiceClient.updateCompletionConfigCallable().futureCall(request); + // Do something. + CompletionConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java new file mode 100644 index 000000000000..7b0ff57fcb8a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.cloud.retail.v2beta.UpdateCompletionConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfig { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfig(); + } + + public static void syncUpdateCompletionConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + UpdateCompletionConfigRequest request = + UpdateCompletionConfigRequest.newBuilder() + .setCompletionConfig(CompletionConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + CompletionConfig response = catalogServiceClient.updateCompletionConfig(request); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java new file mode 100644 index 000000000000..2b7ca86757ac --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogserviceclient/updatecompletionconfig/SyncUpdateCompletionConfigCompletionconfigFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] +import com.google.cloud.retail.v2beta.CatalogServiceClient; +import com.google.cloud.retail.v2beta.CompletionConfig; +import com.google.protobuf.FieldMask; + +public class SyncUpdateCompletionConfigCompletionconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateCompletionConfigCompletionconfigFieldmask(); + } + + public static void syncUpdateCompletionConfigCompletionconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) { + CompletionConfig completionConfig = CompletionConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + CompletionConfig response = + catalogServiceClient.updateCompletionConfig(completionConfig, updateMask); + } + } +} +// [END retail_v2beta_generated_catalogserviceclient_updatecompletionconfig_completionconfigfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..2cbfa3b9d3ca --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/catalogservicesettings/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_catalogservicesettings_updatecatalog_sync] +import com.google.cloud.retail.v2beta.CatalogServiceSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_catalogservicesettings_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/AsyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/AsyncCompleteQuery.java new file mode 100644 index 000000000000..80ddc3d2b4b9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/AsyncCompleteQuery.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_completequery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompleteQueryRequest; +import com.google.cloud.retail.v2beta.CompleteQueryResponse; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import java.util.ArrayList; + +public class AsyncCompleteQuery { + + public static void main(String[] args) throws Exception { + asyncCompleteQuery(); + } + + public static void asyncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + ApiFuture future = + completionServiceClient.completeQueryCallable().futureCall(request); + // Do something. + CompleteQueryResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_completequery_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..d6f90b8d79dc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/completequery/SyncCompleteQuery.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_completequery_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompleteQueryRequest; +import com.google.cloud.retail.v2beta.CompleteQueryResponse; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import java.util.ArrayList; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + CompleteQueryRequest request = + CompleteQueryRequest.newBuilder() + .setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .addAllLanguageCodes(new ArrayList()) + .setDeviceType("deviceType781190832") + .setDataset("dataset1443214456") + .setMaxSuggestions(618824852) + .build(); + CompleteQueryResponse response = completionServiceClient.completeQuery(request); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..3f0b032cf34f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.CompletionServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..2d8d669917ce --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.CompletionServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder() + .setTransportChannelProvider( + CompletionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2beta_generated_completionserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..9d8d7eb17828 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.CompletionServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings completionServiceSettings = + CompletionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CompletionServiceClient completionServiceClient = + CompletionServiceClient.create(completionServiceSettings); + } +} +// [END retail_v2beta_generated_completionserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java new file mode 100644 index 000000000000..963c1452c981 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionData.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_importcompletiondata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompletionDataInputConfig; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.longrunning.Operation; + +public class AsyncImportCompletionData { + + public static void main(String[] args) throws Exception { + asyncImportCompletionData(); + } + + public static void asyncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + completionServiceClient.importCompletionDataCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_importcompletiondata_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java new file mode 100644 index 000000000000..ffac086ca827 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/AsyncImportCompletionDataLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_importcompletiondata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompletionDataInputConfig; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.cloud.retail.v2beta.ImportCompletionDataResponse; +import com.google.cloud.retail.v2beta.ImportMetadata; + +public class AsyncImportCompletionDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportCompletionDataLRO(); + } + + public static void asyncImportCompletionDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + completionServiceClient.importCompletionDataOperationCallable().futureCall(request); + // Do something. + ImportCompletionDataResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_importcompletiondata_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/SyncImportCompletionData.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/SyncImportCompletionData.java new file mode 100644 index 000000000000..86e4ab289fa4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionserviceclient/importcompletiondata/SyncImportCompletionData.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionserviceclient_importcompletiondata_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CompletionDataInputConfig; +import com.google.cloud.retail.v2beta.CompletionServiceClient; +import com.google.cloud.retail.v2beta.ImportCompletionDataRequest; +import com.google.cloud.retail.v2beta.ImportCompletionDataResponse; + +public class SyncImportCompletionData { + + public static void main(String[] args) throws Exception { + syncImportCompletionData(); + } + + public static void syncImportCompletionData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) { + ImportCompletionDataRequest request = + ImportCompletionDataRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(CompletionDataInputConfig.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportCompletionDataResponse response = + completionServiceClient.importCompletionDataAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_completionserviceclient_importcompletiondata_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionservicesettings/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionservicesettings/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..de62c829fe5a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/completionservicesettings/completequery/SyncCompleteQuery.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_completionservicesettings_completequery_sync] +import com.google.cloud.retail.v2beta.CompletionServiceSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceSettings.Builder completionServiceSettingsBuilder = + CompletionServiceSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceSettings completionServiceSettings = completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_completionservicesettings_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..320d38505bd9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ControlServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..3898eca28f07 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ControlServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder() + .setTransportChannelProvider( + ControlServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2beta_generated_controlserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..6faec97b18f8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ControlServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings controlServiceSettings = + ControlServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings); + } +} +// [END retail_v2beta_generated_controlserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/AsyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/AsyncCreateControl.java new file mode 100644 index 000000000000..00f81a93503f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/AsyncCreateControl.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.CreateControlRequest; + +public class AsyncCreateControl { + + public static void main(String[] args) throws Exception { + asyncCreateControl(); + } + + public static void asyncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = controlServiceClient.createControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControl.java new file mode 100644 index 000000000000..8a7b3559df37 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControl.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.CreateControlRequest; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CreateControlRequest request = + CreateControlRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setControl(Control.newBuilder().build()) + .setControlId("controlId-395080872") + .build(); + Control response = controlServiceClient.createControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java new file mode 100644 index 000000000000..6a1be976ccc4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlCatalognameControlString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncCreateControlCatalognameControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlCatalognameControlString(); + } + + public static void syncCreateControlCatalognameControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_catalognamecontrolstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java new file mode 100644 index 000000000000..a0d032c4619c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/createcontrol/SyncCreateControlStringControlString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncCreateControlStringControlString { + + public static void main(String[] args) throws Exception { + syncCreateControlStringControlString(); + } + + public static void syncCreateControlStringControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + Control control = Control.newBuilder().build(); + String controlId = "controlId-395080872"; + Control response = controlServiceClient.createControl(parent, control, controlId); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_createcontrol_stringcontrolstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/AsyncDeleteControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/AsyncDeleteControl.java new file mode 100644 index 000000000000..f8d7faa822d2 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/AsyncDeleteControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteControl { + + public static void main(String[] args) throws Exception { + asyncDeleteControl(); + } + + public static void asyncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.deleteControlCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControl.java new file mode 100644 index 000000000000..c9ad4ff469c4 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_sync] +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.DeleteControlRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteControl { + + public static void main(String[] args) throws Exception { + syncDeleteControl(); + } + + public static void syncDeleteControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + DeleteControlRequest request = + DeleteControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + controlServiceClient.deleteControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java new file mode 100644 index 000000000000..551e17ae7b17 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlControlname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_controlname_sync] +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlControlname { + + public static void main(String[] args) throws Exception { + syncDeleteControlControlname(); + } + + public static void syncDeleteControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_controlname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlString.java new file mode 100644 index 000000000000..9492b9374cf7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/deletecontrol/SyncDeleteControlString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_deletecontrol_string_sync] +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteControlString { + + public static void main(String[] args) throws Exception { + syncDeleteControlString(); + } + + public static void syncDeleteControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + controlServiceClient.deleteControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_deletecontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/AsyncGetControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/AsyncGetControl.java new file mode 100644 index 000000000000..a6c2c60a2c74 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/AsyncGetControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.GetControlRequest; + +public class AsyncGetControl { + + public static void main(String[] args) throws Exception { + asyncGetControl(); + } + + public static void asyncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + ApiFuture future = controlServiceClient.getControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControl.java new file mode 100644 index 000000000000..e19fd69d0e9f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.GetControlRequest; + +public class SyncGetControl { + + public static void main(String[] args) throws Exception { + syncGetControl(); + } + + public static void syncGetControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + GetControlRequest request = + GetControlRequest.newBuilder() + .setName( + ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString()) + .build(); + Control response = controlServiceClient.getControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlControlname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlControlname.java new file mode 100644 index 000000000000..bd7b90c7b60b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlControlname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_controlname_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncGetControlControlname { + + public static void main(String[] args) throws Exception { + syncGetControlControlname(); + } + + public static void syncGetControlControlname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]"); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_controlname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlString.java new file mode 100644 index 000000000000..dab545a1b897 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/getcontrol/SyncGetControlString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_getcontrol_string_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlName; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncGetControlString { + + public static void main(String[] args) throws Exception { + syncGetControlString(); + } + + public static void syncGetControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString(); + Control response = controlServiceClient.getControl(name); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_getcontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControls.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControls.java new file mode 100644 index 000000000000..505b6fc87327 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControls.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ListControlsRequest; + +public class AsyncListControls { + + public static void main(String[] args) throws Exception { + asyncListControls(); + } + + public static void asyncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + controlServiceClient.listControlsPagedCallable().futureCall(request); + // Do something. + for (Control element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControlsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControlsPaged.java new file mode 100644 index 000000000000..71f67e10d269 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/AsyncListControlsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_paged_async] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ListControlsRequest; +import com.google.cloud.retail.v2beta.ListControlsResponse; +import com.google.common.base.Strings; + +public class AsyncListControlsPaged { + + public static void main(String[] args) throws Exception { + asyncListControlsPaged(); + } + + public static void asyncListControlsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListControlsResponse response = controlServiceClient.listControlsCallable().call(request); + for (Control element : response.getControlsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControls.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControls.java new file mode 100644 index 000000000000..01dbd88caf40 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControls.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.ListControlsRequest; + +public class SyncListControls { + + public static void main(String[] args) throws Exception { + syncListControls(); + } + + public static void syncListControls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + ListControlsRequest request = + ListControlsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Control element : controlServiceClient.listControls(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsCatalogname.java new file mode 100644 index 000000000000..8289913fdbaf --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsCatalogname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncListControlsCatalogname { + + public static void main(String[] args) throws Exception { + syncListControlsCatalogname(); + } + + public static void syncListControlsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsString.java new file mode 100644 index 000000000000..c60cb18b2012 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/listcontrols/SyncListControlsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_listcontrols_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; + +public class SyncListControlsString { + + public static void main(String[] args) throws Exception { + syncListControlsString(); + } + + public static void syncListControlsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (Control element : controlServiceClient.listControls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_controlserviceclient_listcontrols_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/AsyncUpdateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/AsyncUpdateControl.java new file mode 100644 index 000000000000..928312da3a43 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/AsyncUpdateControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_updatecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateControl { + + public static void main(String[] args) throws Exception { + asyncUpdateControl(); + } + + public static void asyncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = controlServiceClient.updateControlCallable().futureCall(request); + // Do something. + Control response = future.get(); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_updatecontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControl.java new file mode 100644 index 000000000000..4b3913cf5447 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_updatecontrol_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.cloud.retail.v2beta.UpdateControlRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControl { + + public static void main(String[] args) throws Exception { + syncUpdateControl(); + } + + public static void syncUpdateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + UpdateControlRequest request = + UpdateControlRequest.newBuilder() + .setControl(Control.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Control response = controlServiceClient.updateControl(request); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_updatecontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java new file mode 100644 index 000000000000..dc3f78691c66 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlserviceclient/updatecontrol/SyncUpdateControlControlFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] +import com.google.cloud.retail.v2beta.Control; +import com.google.cloud.retail.v2beta.ControlServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateControlControlFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateControlControlFieldmask(); + } + + public static void syncUpdateControlControlFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) { + Control control = Control.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Control response = controlServiceClient.updateControl(control, updateMask); + } + } +} +// [END retail_v2beta_generated_controlserviceclient_updatecontrol_controlfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlservicesettings/createcontrol/SyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlservicesettings/createcontrol/SyncCreateControl.java new file mode 100644 index 000000000000..86d8b9b2e410 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/controlservicesettings/createcontrol/SyncCreateControl.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_controlservicesettings_createcontrol_sync] +import com.google.cloud.retail.v2beta.ControlServiceSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceSettings.Builder controlServiceSettingsBuilder = + ControlServiceSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_controlservicesettings_createcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..3dd974c19519 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.PredictionServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..3573912450b3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.PredictionServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder() + .setTransportChannelProvider( + PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2beta_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..551d1f23cf76 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.PredictionServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings predictionServiceSettings = + PredictionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + PredictionServiceClient predictionServiceClient = + PredictionServiceClient.create(predictionServiceSettings); + } +} +// [END retail_v2beta_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/AsyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 000000000000..a9c14f7ddbbf --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/AsyncPredict.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.PredictRequest; +import com.google.cloud.retail.v2beta.PredictResponse; +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class AsyncPredict { + + public static void main(String[] args) throws Exception { + asyncPredict(); + } + + public static void asyncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_predictionserviceclient_predict_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 000000000000..d30a345b6381 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionserviceclient/predict/SyncPredict.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionserviceclient_predict_sync] +import com.google.cloud.retail.v2beta.PredictRequest; +import com.google.cloud.retail.v2beta.PredictResponse; +import com.google.cloud.retail.v2beta.PredictionServiceClient; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.protobuf.Value; +import java.util.HashMap; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) { + PredictRequest request = + PredictRequest.newBuilder() + .setPlacement("placement1792938725") + .setUserEvent(UserEvent.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setValidateOnly(true) + .putAllParams(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END retail_v2beta_generated_predictionserviceclient_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionservicesettings/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 000000000000..4bcc21509a40 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/predictionservicesettings/predict/SyncPredict.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_predictionservicesettings_predict_sync] +import com.google.cloud.retail.v2beta.PredictionServiceSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceSettings predictionServiceSettings = predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_predictionservicesettings_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java new file mode 100644 index 000000000000..341a62310800 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlaces(); + } + + public static void asyncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java new file mode 100644 index 000000000000..29ebf11a7bf1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/AsyncAddFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncAddFulfillmentPlacesLRO(); + } + + public static void asyncAddFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + AddFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java new file mode 100644 index 000000000000..7d87a8e50792 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_sync] +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlaces(); + } + + public static void syncAddFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddFulfillmentPlacesRequest request = + AddFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java new file mode 100644 index 000000000000..6d2cfb0b80ab --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesProductname(); + } + + public static void syncAddFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java new file mode 100644 index 000000000000..fcf770166bd3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addfulfillmentplaces/SyncAddFulfillmentPlacesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addfulfillmentplaces_string_sync] +import com.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncAddFulfillmentPlacesString(); + } + + public static void syncAddFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddFulfillmentPlacesResponse response = + productServiceClient.addFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addfulfillmentplaces_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java new file mode 100644 index 000000000000..6ad09148eb70 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventories.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.LocalInventory; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventories(); + } + + public static void asyncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.addLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java new file mode 100644 index 000000000000..bd587cb6ed90 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/AsyncAddLocalInventoriesLRO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.AddLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.LocalInventory; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncAddLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncAddLocalInventoriesLRO(); + } + + public static void asyncAddLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.addLocalInventoriesOperationCallable().futureCall(request); + // Do something. + AddLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventories.java new file mode 100644 index 000000000000..e6df6c494482 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_sync] +import com.google.cloud.retail.v2beta.AddLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.LocalInventory; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncAddLocalInventories { + + public static void main(String[] args) throws Exception { + syncAddLocalInventories(); + } + + public static void syncAddLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + AddLocalInventoriesRequest request = + AddLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllLocalInventories(new ArrayList()) + .setAddMask(FieldMask.newBuilder().build()) + .setAddTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java new file mode 100644 index 000000000000..77edad20a3bb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_productname_sync] +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesProductname(); + } + + public static void syncAddLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java new file mode 100644 index 000000000000..4cf735a55a4f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/addlocalinventories/SyncAddLocalInventoriesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_addlocalinventories_string_sync] +import com.google.cloud.retail.v2beta.AddLocalInventoriesResponse; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncAddLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncAddLocalInventoriesString(); + } + + public static void syncAddLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + AddLocalInventoriesResponse response = + productServiceClient.addLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_addlocalinventories_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..9986ddc27797 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.ProductServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2beta_generated_productserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..47cc8acd476e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.ProductServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder() + .setTransportChannelProvider( + ProductServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2beta_generated_productserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..a091791f5777 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.ProductServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings productServiceSettings = + ProductServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProductServiceClient productServiceClient = ProductServiceClient.create(productServiceSettings); + } +} +// [END retail_v2beta_generated_productserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/AsyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/AsyncCreateProduct.java new file mode 100644 index 000000000000..6316aba5e3e1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/AsyncCreateProduct.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CreateProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class AsyncCreateProduct { + + public static void main(String[] args) throws Exception { + asyncCreateProduct(); + } + + public static void asyncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + ApiFuture future = productServiceClient.createProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..0d6b1b40f515 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.CreateProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + CreateProductRequest request = + CreateProductRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setProduct(Product.newBuilder().build()) + .setProductId("productId-1051830678") + .build(); + Product response = productServiceClient.createProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java new file mode 100644 index 000000000000..53908457e689 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductBranchnameProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_branchnameproductstring_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncCreateProductBranchnameProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductBranchnameProductString(); + } + + public static void syncCreateProductBranchnameProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_branchnameproductstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductStringProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductStringProductString.java new file mode 100644 index 000000000000..abc7c58773ad --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/createproduct/SyncCreateProductStringProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_createproduct_stringproductstring_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncCreateProductStringProductString { + + public static void main(String[] args) throws Exception { + syncCreateProductStringProductString(); + } + + public static void syncCreateProductStringProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + Product product = Product.newBuilder().build(); + String productId = "productId-1051830678"; + Product response = productServiceClient.createProduct(parent, product, productId); + } + } +} +// [END retail_v2beta_generated_productserviceclient_createproduct_stringproductstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/AsyncDeleteProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/AsyncDeleteProduct.java new file mode 100644 index 000000000000..5a079e79cd94 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/AsyncDeleteProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.DeleteProductRequest; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteProduct { + + public static void main(String[] args) throws Exception { + asyncDeleteProduct(); + } + + public static void asyncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.deleteProductCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProduct.java new file mode 100644 index 000000000000..d4c19bd5835a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_sync] +import com.google.cloud.retail.v2beta.DeleteProductRequest; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProduct { + + public static void main(String[] args) throws Exception { + syncDeleteProduct(); + } + + public static void syncDeleteProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + DeleteProductRequest request = + DeleteProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + productServiceClient.deleteProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductProductname.java new file mode 100644 index 000000000000..18e28c282216 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductProductname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_productname_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProductProductname { + + public static void main(String[] args) throws Exception { + syncDeleteProductProductname(); + } + + public static void syncDeleteProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductString.java new file mode 100644 index 000000000000..6fcef4503537 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/deleteproduct/SyncDeleteProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_deleteproduct_string_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteProductString { + + public static void main(String[] args) throws Exception { + syncDeleteProductString(); + } + + public static void syncDeleteProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + productServiceClient.deleteProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_deleteproduct_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/AsyncGetProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/AsyncGetProduct.java new file mode 100644 index 000000000000..ced473d9426f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/AsyncGetProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.GetProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class AsyncGetProduct { + + public static void main(String[] args) throws Exception { + asyncGetProduct(); + } + + public static void asyncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + ApiFuture future = productServiceClient.getProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProduct.java new file mode 100644 index 000000000000..c777816fe418 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_sync] +import com.google.cloud.retail.v2beta.GetProductRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncGetProduct { + + public static void main(String[] args) throws Exception { + syncGetProduct(); + } + + public static void syncGetProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + GetProductRequest request = + GetProductRequest.newBuilder() + .setName( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .build(); + Product response = productServiceClient.getProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductProductname.java new file mode 100644 index 000000000000..f6e6d7aff05c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductProductname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_productname_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncGetProductProductname { + + public static void main(String[] args) throws Exception { + syncGetProductProductname(); + } + + public static void syncGetProductProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductString.java new file mode 100644 index 000000000000..8bc84b634cd0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/getproduct/SyncGetProductString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_getproduct_string_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncGetProductString { + + public static void main(String[] args) throws Exception { + syncGetProductString(); + } + + public static void syncGetProductString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String name = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + Product response = productServiceClient.getProduct(name); + } + } +} +// [END retail_v2beta_generated_productserviceclient_getproduct_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProducts.java new file mode 100644 index 000000000000..c1705d52976c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProducts.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_importproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ProductInputConfig; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncImportProducts { + + public static void main(String[] args) throws Exception { + asyncImportProducts(); + } + + public static void asyncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ApiFuture future = + productServiceClient.importProductsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_importproducts_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProductsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProductsLRO.java new file mode 100644 index 000000000000..a9181657db89 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/AsyncImportProductsLRO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_importproducts_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ImportProductsResponse; +import com.google.cloud.retail.v2beta.ProductInputConfig; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncImportProductsLRO { + + public static void main(String[] args) throws Exception { + asyncImportProductsLRO(); + } + + public static void asyncImportProductsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + OperationFuture future = + productServiceClient.importProductsOperationCallable().futureCall(request); + // Do something. + ImportProductsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_importproducts_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/SyncImportProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/SyncImportProducts.java new file mode 100644 index 000000000000..2303e88006e8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/importproducts/SyncImportProducts.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_importproducts_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportProductsRequest; +import com.google.cloud.retail.v2beta.ImportProductsResponse; +import com.google.cloud.retail.v2beta.ProductInputConfig; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncImportProducts { + + public static void main(String[] args) throws Exception { + syncImportProducts(); + } + + public static void syncImportProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ImportProductsRequest request = + ImportProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setRequestId("requestId693933066") + .setInputConfig(ProductInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setNotificationPubsubTopic("notificationPubsubTopic-1361224991") + .build(); + ImportProductsResponse response = productServiceClient.importProductsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_importproducts_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProducts.java new file mode 100644 index 000000000000..584111ee1874 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProducts.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncListProducts { + + public static void main(String[] args) throws Exception { + asyncListProducts(); + } + + public static void asyncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + productServiceClient.listProductsPagedCallable().futureCall(request); + // Do something. + for (Product element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProductsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProductsPaged.java new file mode 100644 index 000000000000..a41c9ed97eee --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/AsyncListProductsPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_paged_async] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.ListProductsResponse; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +public class AsyncListProductsPaged { + + public static void main(String[] args) throws Exception { + asyncListProductsPaged(); + } + + public static void asyncListProductsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + while (true) { + ListProductsResponse response = productServiceClient.listProductsCallable().call(request); + for (Product element : response.getProductsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProducts.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProducts.java new file mode 100644 index 000000000000..0eb6d9914ad5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProducts.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.ListProductsRequest; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncListProducts { + + public static void main(String[] args) throws Exception { + syncListProducts(); + } + + public static void syncListProducts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ListProductsRequest request = + ListProductsRequest.newBuilder() + .setParent( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setReadMask(FieldMask.newBuilder().build()) + .build(); + for (Product element : productServiceClient.listProducts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsBranchname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsBranchname.java new file mode 100644 index 000000000000..4acc10286f51 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsBranchname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_branchname_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncListProductsBranchname { + + public static void main(String[] args) throws Exception { + syncListProductsBranchname(); + } + + public static void syncListProductsBranchname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_branchname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsString.java new file mode 100644 index 000000000000..64e4770bfbb3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/listproducts/SyncListProductsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_listproducts_string_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; + +public class SyncListProductsString { + + public static void main(String[] args) throws Exception { + syncListProductsString(); + } + + public static void syncListProductsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString(); + for (Product element : productServiceClient.listProducts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_productserviceclient_listproducts_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java new file mode 100644 index 000000000000..acdcc3f0ebcc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlaces.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlaces(); + } + + public static void asyncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeFulfillmentPlacesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java new file mode 100644 index 000000000000..b602d1a6244a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/AsyncRemoveFulfillmentPlacesLRO.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveFulfillmentPlacesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveFulfillmentPlacesLRO(); + } + + public static void asyncRemoveFulfillmentPlacesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeFulfillmentPlacesOperationCallable().futureCall(request); + // Do something. + RemoveFulfillmentPlacesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java new file mode 100644 index 000000000000..c397f9e3c489 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveFulfillmentPlaces { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlaces(); + } + + public static void syncRemoveFulfillmentPlaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveFulfillmentPlacesRequest request = + RemoveFulfillmentPlacesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .setType("type3575610") + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java new file mode 100644 index 000000000000..7fe6359d52f3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_productname_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesProductname(); + } + + public static void syncRemoveFulfillmentPlacesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java new file mode 100644 index 000000000000..9e98617176cd --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removefulfillmentplaces/SyncRemoveFulfillmentPlacesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removefulfillmentplaces_string_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + +public class SyncRemoveFulfillmentPlacesString { + + public static void main(String[] args) throws Exception { + syncRemoveFulfillmentPlacesString(); + } + + public static void syncRemoveFulfillmentPlacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveFulfillmentPlacesResponse response = + productServiceClient.removeFulfillmentPlacesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removefulfillmentplaces_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java new file mode 100644 index 000000000000..85326af9824e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventories(); + } + + public static void asyncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = + productServiceClient.removeLocalInventoriesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java new file mode 100644 index 000000000000..96959e7be0bc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/AsyncRemoveLocalInventoriesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class AsyncRemoveLocalInventoriesLRO { + + public static void main(String[] args) throws Exception { + asyncRemoveLocalInventoriesLRO(); + } + + public static void asyncRemoveLocalInventoriesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.removeLocalInventoriesOperationCallable().futureCall(request); + // Do something. + RemoveLocalInventoriesResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java new file mode 100644 index 000000000000..600bfe2c9c8b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventories.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; + +public class SyncRemoveLocalInventories { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventories(); + } + + public static void syncRemoveLocalInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + RemoveLocalInventoriesRequest request = + RemoveLocalInventoriesRequest.newBuilder() + .setProduct( + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString()) + .addAllPlaceIds(new ArrayList()) + .setRemoveTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java new file mode 100644 index 000000000000..0de3e63256fc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesProductname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_productname_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesProductname { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesProductname(); + } + + public static void syncRemoveLocalInventoriesProductname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + ProductName product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_productname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java new file mode 100644 index 000000000000..991c42f6321d --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/removelocalinventories/SyncRemoveLocalInventoriesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_removelocalinventories_string_sync] +import com.google.cloud.retail.v2beta.ProductName; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + +public class SyncRemoveLocalInventoriesString { + + public static void main(String[] args) throws Exception { + syncRemoveLocalInventoriesString(); + } + + public static void syncRemoveLocalInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + String product = + ProductName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]") + .toString(); + RemoveLocalInventoriesResponse response = + productServiceClient.removeLocalInventoriesAsync(product).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_removelocalinventories_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventory.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventory.java new file mode 100644 index 000000000000..ee08a61b3a40 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventory.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventory { + + public static void main(String[] args) throws Exception { + asyncSetInventory(); + } + + public static void asyncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.setInventoryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventoryLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventoryLRO.java new file mode 100644 index 000000000000..a4a7210ce6f1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/AsyncSetInventoryLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryMetadata; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncSetInventoryLRO { + + public static void main(String[] args) throws Exception { + asyncSetInventoryLRO(); + } + + public static void asyncSetInventoryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + OperationFuture future = + productServiceClient.setInventoryOperationCallable().futureCall(request); + // Do something. + SetInventoryResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventory.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventory.java new file mode 100644 index 000000000000..930717b5edec --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventory.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryRequest; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncSetInventory { + + public static void main(String[] args) throws Exception { + syncSetInventory(); + } + + public static void syncSetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + SetInventoryRequest request = + SetInventoryRequest.newBuilder() + .setInventory(Product.newBuilder().build()) + .setSetMask(FieldMask.newBuilder().build()) + .setSetTime(Timestamp.newBuilder().build()) + .setAllowMissing(true) + .build(); + SetInventoryResponse response = productServiceClient.setInventoryAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java new file mode 100644 index 000000000000..2d6a34938c03 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/setinventory/SyncSetInventoryProductFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_setinventory_productfieldmask_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.SetInventoryResponse; +import com.google.protobuf.FieldMask; + +public class SyncSetInventoryProductFieldmask { + + public static void main(String[] args) throws Exception { + syncSetInventoryProductFieldmask(); + } + + public static void syncSetInventoryProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product inventory = Product.newBuilder().build(); + FieldMask setMask = FieldMask.newBuilder().build(); + SetInventoryResponse response = + productServiceClient.setInventoryAsync(inventory, setMask).get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_setinventory_productfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/AsyncUpdateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/AsyncUpdateProduct.java new file mode 100644 index 000000000000..4ca112ed14b0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/AsyncUpdateProduct.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_updateproduct_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProduct { + + public static void main(String[] args) throws Exception { + asyncUpdateProduct(); + } + + public static void asyncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + ApiFuture future = productServiceClient.updateProductCallable().futureCall(request); + // Do something. + Product response = future.get(); + } + } +} +// [END retail_v2beta_generated_productserviceclient_updateproduct_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProduct.java new file mode 100644 index 000000000000..d4ee629207cf --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProduct.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_updateproduct_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.cloud.retail.v2beta.UpdateProductRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProduct { + + public static void main(String[] args) throws Exception { + syncUpdateProduct(); + } + + public static void syncUpdateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + UpdateProductRequest request = + UpdateProductRequest.newBuilder() + .setProduct(Product.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowMissing(true) + .build(); + Product response = productServiceClient.updateProduct(request); + } + } +} +// [END retail_v2beta_generated_productserviceclient_updateproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java new file mode 100644 index 000000000000..ea64bfa3d72a --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productserviceclient/updateproduct/SyncUpdateProductProductFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productserviceclient_updateproduct_productfieldmask_sync] +import com.google.cloud.retail.v2beta.Product; +import com.google.cloud.retail.v2beta.ProductServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProductProductFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProductProductFieldmask(); + } + + public static void syncUpdateProductProductFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProductServiceClient productServiceClient = ProductServiceClient.create()) { + Product product = Product.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Product response = productServiceClient.updateProduct(product, updateMask); + } + } +} +// [END retail_v2beta_generated_productserviceclient_updateproduct_productfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productservicesettings/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productservicesettings/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..76eb39a0d641 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/productservicesettings/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_productservicesettings_createproduct_sync] +import com.google.cloud.retail.v2beta.ProductServiceSettings; +import java.time.Duration; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceSettings.Builder productServiceSettingsBuilder = + ProductServiceSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_productservicesettings_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..d2d0cd06b8fa --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.SearchServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..3dceef447330 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.SearchServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder() + .setTransportChannelProvider( + SearchServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2beta_generated_searchserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..ec26b519e154 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.SearchServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings searchServiceSettings = + SearchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings); + } +} +// [END retail_v2beta_generated_searchserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearch.java new file mode 100644 index 000000000000..8e9c16ec1106 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearch.java @@ -0,0 +1,69 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_search_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.UserInfo; +import java.util.ArrayList; + +public class AsyncSearch { + + public static void main(String[] args) throws Exception { + asyncSearch(); + } + + public static void asyncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + ApiFuture future = + searchServiceClient.searchPagedCallable().futureCall(request); + // Do something. + for (SearchResponse.SearchResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_searchserviceclient_search_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearchPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearchPaged.java new file mode 100644 index 000000000000..48cdb363b2d1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/AsyncSearchPaged.java @@ -0,0 +1,75 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_search_paged_async] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.UserInfo; +import com.google.common.base.Strings; +import java.util.ArrayList; + +public class AsyncSearchPaged { + + public static void main(String[] args) throws Exception { + asyncSearchPaged(); + } + + public static void asyncSearchPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + while (true) { + SearchResponse response = searchServiceClient.searchCallable().call(request); + for (SearchResponse.SearchResult element : response.getResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_searchserviceclient_search_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/SyncSearch.java new file mode 100644 index 000000000000..f2fc2b9d8b95 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchserviceclient/search/SyncSearch.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchserviceclient_search_sync] +import com.google.cloud.retail.v2beta.BranchName; +import com.google.cloud.retail.v2beta.SearchRequest; +import com.google.cloud.retail.v2beta.SearchResponse; +import com.google.cloud.retail.v2beta.SearchServiceClient; +import com.google.cloud.retail.v2beta.UserInfo; +import java.util.ArrayList; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) { + SearchRequest request = + SearchRequest.newBuilder() + .setPlacement("placement1792938725") + .setBranch( + BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString()) + .setQuery("query107944136") + .setVisitorId("visitorId1880545833") + .setUserInfo(UserInfo.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOffset(-1019779949) + .setFilter("filter-1274492040") + .setCanonicalFilter("canonicalFilter-722283124") + .setOrderBy("orderBy-1207110587") + .addAllFacetSpecs(new ArrayList()) + .setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build()) + .setBoostSpec(SearchRequest.BoostSpec.newBuilder().build()) + .setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build()) + .addAllVariantRollupKeys(new ArrayList()) + .addAllPageCategories(new ArrayList()) + .setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build()) + .build(); + for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_searchserviceclient_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchservicesettings/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchservicesettings/search/SyncSearch.java new file mode 100644 index 000000000000..53b373a68732 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/searchservicesettings/search/SyncSearch.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_searchservicesettings_search_sync] +import com.google.cloud.retail.v2beta.SearchServiceSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceSettings.Builder searchServiceSettingsBuilder = SearchServiceSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_searchservicesettings_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/AsyncAddControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/AsyncAddControl.java new file mode 100644 index 000000000000..65c976691fc9 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/AsyncAddControl.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.AddControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncAddControl { + + public static void main(String[] args) throws Exception { + asyncAddControl(); + } + + public static void asyncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.addControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControl.java new file mode 100644 index 000000000000..fa39829fb204 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_sync] +import com.google.cloud.retail.v2beta.AddControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncAddControl { + + public static void main(String[] args) throws Exception { + syncAddControl(); + } + + public static void syncAddControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + AddControlRequest request = + AddControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.addControl(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java new file mode 100644 index 000000000000..05e947e1995b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncAddControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncAddControlServingconfigname(); + } + + public static void syncAddControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlString.java new file mode 100644 index 000000000000..9b3f6373a2fa --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/addcontrol/SyncAddControlString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_addcontrol_string_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncAddControlString { + + public static void main(String[] args) throws Exception { + syncAddControlString(); + } + + public static void syncAddControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.addControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_addcontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..a725d416252b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..6bb86f6db2d8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + ServingConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..1935777ad793 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings servingConfigServiceSettings = + ServingConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create(servingConfigServiceSettings); + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java new file mode 100644 index 000000000000..9d26ccaf3888 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/AsyncCreateServingConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CreateServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + asyncCreateServingConfig(); + } + + public static void asyncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ApiFuture future = + servingConfigServiceClient.createServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 000000000000..409103d89482 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfig.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.CreateServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CreateServingConfigRequest request = + CreateServingConfigRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setServingConfig(ServingConfig.newBuilder().build()) + .setServingConfigId("servingConfigId-831052759") + .build(); + ServingConfig response = servingConfigServiceClient.createServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java new file mode 100644 index 000000000000..7f4e7a1c1bb8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigCatalognameServingconfigString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncCreateServingConfigCatalognameServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigCatalognameServingconfigString(); + } + + public static void syncCreateServingConfigCatalognameServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_catalognameservingconfigstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java new file mode 100644 index 000000000000..17432dab3af0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/createservingconfig/SyncCreateServingConfigStringServingconfigString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncCreateServingConfigStringServingconfigString { + + public static void main(String[] args) throws Exception { + syncCreateServingConfigStringServingconfigString(); + } + + public static void syncCreateServingConfigStringServingconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + String servingConfigId = "servingConfigId-831052759"; + ServingConfig response = + servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_createservingconfig_stringservingconfigstring_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java new file mode 100644 index 000000000000..b1a8431de952 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/AsyncDeleteServingConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.DeleteServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteServingConfig(); + } + + public static void asyncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.deleteServingConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java new file mode 100644 index 000000000000..0151b52c32e8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfig.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_sync] +import com.google.cloud.retail.v2beta.DeleteServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfig { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfig(); + } + + public static void syncDeleteServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + DeleteServingConfigRequest request = + DeleteServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + servingConfigServiceClient.deleteServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java new file mode 100644 index 000000000000..4a869a90cb23 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigServingconfigname(); + } + + public static void syncDeleteServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java new file mode 100644 index 000000000000..9436e1469e34 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/deleteservingconfig/SyncDeleteServingConfigString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_string_sync] +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteServingConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteServingConfigString(); + } + + public static void syncDeleteServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + servingConfigServiceClient.deleteServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_deleteservingconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java new file mode 100644 index 000000000000..d7f4718b55dc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/AsyncGetServingConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.GetServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncGetServingConfig { + + public static void main(String[] args) throws Exception { + asyncGetServingConfig(); + } + + public static void asyncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ApiFuture future = + servingConfigServiceClient.getServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java new file mode 100644 index 000000000000..1c7dee2cbebb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfig.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_sync] +import com.google.cloud.retail.v2beta.GetServingConfigRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncGetServingConfig { + + public static void main(String[] args) throws Exception { + syncGetServingConfig(); + } + + public static void syncGetServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + GetServingConfigRequest request = + GetServingConfigRequest.newBuilder() + .setName( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .build(); + ServingConfig response = servingConfigServiceClient.getServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java new file mode 100644 index 000000000000..063db1075177 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncGetServingConfigServingconfigname { + + public static void main(String[] args) throws Exception { + syncGetServingConfigServingconfigname(); + } + + public static void syncGetServingConfigServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java new file mode 100644 index 000000000000..683933361533 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/getservingconfig/SyncGetServingConfigString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_getservingconfig_string_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncGetServingConfigString { + + public static void main(String[] args) throws Exception { + syncGetServingConfigString(); + } + + public static void syncGetServingConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String name = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.getServingConfig(name); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_getservingconfig_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java new file mode 100644 index 000000000000..9eda4ea4fc7e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigs.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncListServingConfigs { + + public static void main(String[] args) throws Exception { + asyncListServingConfigs(); + } + + public static void asyncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + servingConfigServiceClient.listServingConfigsPagedCallable().futureCall(request); + // Do something. + for (ServingConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java new file mode 100644 index 000000000000..6d71bde67575 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/AsyncListServingConfigsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_paged_async] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ListServingConfigsResponse; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.common.base.Strings; + +public class AsyncListServingConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListServingConfigsPaged(); + } + + public static void asyncListServingConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListServingConfigsResponse response = + servingConfigServiceClient.listServingConfigsCallable().call(request); + for (ServingConfig element : response.getServingConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_paged_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java new file mode 100644 index 000000000000..6ceca20ac1cc --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigs.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ListServingConfigsRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncListServingConfigs { + + public static void main(String[] args) throws Exception { + syncListServingConfigs(); + } + + public static void syncListServingConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ListServingConfigsRequest request = + ListServingConfigsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java new file mode 100644 index 000000000000..7f3ffaac3ab1 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsCatalogname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncListServingConfigsCatalogname { + + public static void main(String[] args) throws Exception { + syncListServingConfigsCatalogname(); + } + + public static void syncListServingConfigsCatalogname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_catalogname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java new file mode 100644 index 000000000000..761d016449ba --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/listservingconfigs/SyncListServingConfigsString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_string_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncListServingConfigsString { + + public static void main(String[] args) throws Exception { + syncListServingConfigsString(); + } + + public static void syncListServingConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); + for (ServingConfig element : + servingConfigServiceClient.listServingConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_listservingconfigs_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java new file mode 100644 index 000000000000..c919c6710851 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/AsyncRemoveControl.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.RemoveControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class AsyncRemoveControl { + + public static void main(String[] args) throws Exception { + asyncRemoveControl(); + } + + public static void asyncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ApiFuture future = + servingConfigServiceClient.removeControlCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControl.java new file mode 100644 index 000000000000..590eb21558bf --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_sync] +import com.google.cloud.retail.v2beta.RemoveControlRequest; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncRemoveControl { + + public static void main(String[] args) throws Exception { + syncRemoveControl(); + } + + public static void syncRemoveControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + RemoveControlRequest request = + RemoveControlRequest.newBuilder() + .setServingConfig( + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString()) + .setControlId("controlId-395080872") + .build(); + ServingConfig response = servingConfigServiceClient.removeControl(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java new file mode 100644 index 000000000000..03424a2f5d03 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlServingconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncRemoveControlServingconfigname { + + public static void main(String[] args) throws Exception { + syncRemoveControlServingconfigname(); + } + + public static void syncRemoveControlServingconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfigName servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]"); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_servingconfigname_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java new file mode 100644 index 000000000000..44367cc26dea --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/removecontrol/SyncRemoveControlString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_removecontrol_string_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigName; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; + +public class SyncRemoveControlString { + + public static void main(String[] args) throws Exception { + syncRemoveControlString(); + } + + public static void syncRemoveControlString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + String servingConfig = + ServingConfigName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[SERVING_CONFIG]") + .toString(); + ServingConfig response = servingConfigServiceClient.removeControl(servingConfig); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_removecontrol_string_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java new file mode 100644 index 000000000000..216df01b5198 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/AsyncUpdateServingConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateServingConfig(); + } + + public static void asyncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + servingConfigServiceClient.updateServingConfigCallable().futureCall(request); + // Do something. + ServingConfig response = future.get(); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java new file mode 100644 index 000000000000..b7f653062557 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.cloud.retail.v2beta.UpdateServingConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfig { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfig(); + } + + public static void syncUpdateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + UpdateServingConfigRequest request = + UpdateServingConfigRequest.newBuilder() + .setServingConfig(ServingConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ServingConfig response = servingConfigServiceClient.updateServingConfig(request); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java new file mode 100644 index 000000000000..f0f24d822a4f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigserviceclient/updateservingconfig/SyncUpdateServingConfigServingconfigFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] +import com.google.cloud.retail.v2beta.ServingConfig; +import com.google.cloud.retail.v2beta.ServingConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServingConfigServingconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateServingConfigServingconfigFieldmask(); + } + + public static void syncUpdateServingConfigServingconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ServingConfigServiceClient servingConfigServiceClient = + ServingConfigServiceClient.create()) { + ServingConfig servingConfig = ServingConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ServingConfig response = + servingConfigServiceClient.updateServingConfig(servingConfig, updateMask); + } + } +} +// [END retail_v2beta_generated_servingconfigserviceclient_updateservingconfig_servingconfigfieldmask_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 000000000000..05930f6a38d8 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/servingconfigservicesettings/createservingconfig/SyncCreateServingConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_servingconfigservicesettings_createservingconfig_sync] +import com.google.cloud.retail.v2beta.ServingConfigServiceSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_servingconfigservicesettings_createservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java new file mode 100644 index 000000000000..461df87b9b64 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/catalogservicestubsettings/updatecatalog/SyncUpdateCatalog.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_catalogservicestubsettings_updatecatalog_sync] +import com.google.cloud.retail.v2beta.stub.CatalogServiceStubSettings; +import java.time.Duration; + +public class SyncUpdateCatalog { + + public static void main(String[] args) throws Exception { + syncUpdateCatalog(); + } + + public static void syncUpdateCatalog() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CatalogServiceStubSettings.Builder catalogServiceSettingsBuilder = + CatalogServiceStubSettings.newBuilder(); + catalogServiceSettingsBuilder + .updateCatalogSettings() + .setRetrySettings( + catalogServiceSettingsBuilder + .updateCatalogSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CatalogServiceStubSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_catalogservicestubsettings_updatecatalog_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java new file mode 100644 index 000000000000..6916d8a2d5ae --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/completionservicestubsettings/completequery/SyncCompleteQuery.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_completionservicestubsettings_completequery_sync] +import com.google.cloud.retail.v2beta.stub.CompletionServiceStubSettings; +import java.time.Duration; + +public class SyncCompleteQuery { + + public static void main(String[] args) throws Exception { + syncCompleteQuery(); + } + + public static void syncCompleteQuery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CompletionServiceStubSettings.Builder completionServiceSettingsBuilder = + CompletionServiceStubSettings.newBuilder(); + completionServiceSettingsBuilder + .completeQuerySettings() + .setRetrySettings( + completionServiceSettingsBuilder + .completeQuerySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CompletionServiceStubSettings completionServiceSettings = + completionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_completionservicestubsettings_completequery_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java new file mode 100644 index 000000000000..d43bb3e18e66 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/controlservicestubsettings/createcontrol/SyncCreateControl.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_controlservicestubsettings_createcontrol_sync] +import com.google.cloud.retail.v2beta.stub.ControlServiceStubSettings; +import java.time.Duration; + +public class SyncCreateControl { + + public static void main(String[] args) throws Exception { + syncCreateControl(); + } + + public static void syncCreateControl() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ControlServiceStubSettings.Builder controlServiceSettingsBuilder = + ControlServiceStubSettings.newBuilder(); + controlServiceSettingsBuilder + .createControlSettings() + .setRetrySettings( + controlServiceSettingsBuilder + .createControlSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ControlServiceStubSettings controlServiceSettings = controlServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_controlservicestubsettings_createcontrol_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/predictionservicestubsettings/predict/SyncPredict.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 000000000000..b60cbc9a515e --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/predictionservicestubsettings/predict/SyncPredict.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.retail.v2beta.stub.PredictionServiceStubSettings; +import java.time.Duration; + +public class SyncPredict { + + public static void main(String[] args) throws Exception { + syncPredict(); + } + + public static void syncPredict() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PredictionServiceStubSettings.Builder predictionServiceSettingsBuilder = + PredictionServiceStubSettings.newBuilder(); + predictionServiceSettingsBuilder + .predictSettings() + .setRetrySettings( + predictionServiceSettingsBuilder + .predictSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PredictionServiceStubSettings predictionServiceSettings = + predictionServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_predictionservicestubsettings_predict_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/productservicestubsettings/createproduct/SyncCreateProduct.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/productservicestubsettings/createproduct/SyncCreateProduct.java new file mode 100644 index 000000000000..0db7c0f82b57 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/productservicestubsettings/createproduct/SyncCreateProduct.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_productservicestubsettings_createproduct_sync] +import com.google.cloud.retail.v2beta.stub.ProductServiceStubSettings; +import java.time.Duration; + +public class SyncCreateProduct { + + public static void main(String[] args) throws Exception { + syncCreateProduct(); + } + + public static void syncCreateProduct() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProductServiceStubSettings.Builder productServiceSettingsBuilder = + ProductServiceStubSettings.newBuilder(); + productServiceSettingsBuilder + .createProductSettings() + .setRetrySettings( + productServiceSettingsBuilder + .createProductSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProductServiceStubSettings productServiceSettings = productServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_productservicestubsettings_createproduct_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/searchservicestubsettings/search/SyncSearch.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/searchservicestubsettings/search/SyncSearch.java new file mode 100644 index 000000000000..4ed391098b9b --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/searchservicestubsettings/search/SyncSearch.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_searchservicestubsettings_search_sync] +import com.google.cloud.retail.v2beta.stub.SearchServiceStubSettings; +import java.time.Duration; + +public class SyncSearch { + + public static void main(String[] args) throws Exception { + syncSearch(); + } + + public static void syncSearch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SearchServiceStubSettings.Builder searchServiceSettingsBuilder = + SearchServiceStubSettings.newBuilder(); + searchServiceSettingsBuilder + .searchSettings() + .setRetrySettings( + searchServiceSettingsBuilder + .searchSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SearchServiceStubSettings searchServiceSettings = searchServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_searchservicestubsettings_search_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java new file mode 100644 index 000000000000..3caaf3b007cb --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/servingconfigservicestubsettings/createservingconfig/SyncCreateServingConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_servingconfigservicestubsettings_createservingconfig_sync] +import com.google.cloud.retail.v2beta.stub.ServingConfigServiceStubSettings; +import java.time.Duration; + +public class SyncCreateServingConfig { + + public static void main(String[] args) throws Exception { + syncCreateServingConfig(); + } + + public static void syncCreateServingConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ServingConfigServiceStubSettings.Builder servingConfigServiceSettingsBuilder = + ServingConfigServiceStubSettings.newBuilder(); + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .setRetrySettings( + servingConfigServiceSettingsBuilder + .createServingConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ServingConfigServiceStubSettings servingConfigServiceSettings = + servingConfigServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_servingconfigservicestubsettings_createservingconfig_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..9218068640bd --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/stub/usereventservicestubsettings/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.stub.samples; + +// [START retail_v2beta_generated_usereventservicestubsettings_writeuserevent_sync] +import com.google.cloud.retail.v2beta.stub.UserEventServiceStubSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceStubSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceStubSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceStubSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_usereventservicestubsettings_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java new file mode 100644 index 000000000000..0992bf520f13 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/AsyncCollectUserEvent.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_collectuserevent_async] +import com.google.api.HttpBody; +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CollectUserEventRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + asyncCollectUserEvent(); + } + + public static void asyncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + ApiFuture future = + userEventServiceClient.collectUserEventCallable().futureCall(request); + // Do something. + HttpBody response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_collectuserevent_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java new file mode 100644 index 000000000000..893ec1ee2d2c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/collectuserevent/SyncCollectUserEvent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_collectuserevent_sync] +import com.google.api.HttpBody; +import com.google.cloud.retail.v2beta.CollectUserEventRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncCollectUserEvent { + + public static void main(String[] args) throws Exception { + syncCollectUserEvent(); + } + + public static void syncCollectUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + CollectUserEventRequest request = + CollectUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent("userEvent315571599") + .setUri("uri116076") + .setEts(100772) + .build(); + HttpBody response = userEventServiceClient.collectUserEvent(request); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_collectuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..18bc722d237c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.UserEventServiceSettings; +import com.google.cloud.retail.v2beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..986326938684 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.UserEventServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder() + .setTransportChannelProvider( + UserEventServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2beta_generated_usereventserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetEndpoint.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..f362a95875d3 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_create_setendpoint_sync] +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.UserEventServiceSettings; +import com.google.cloud.retail.v2beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings userEventServiceSettings = + UserEventServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + UserEventServiceClient userEventServiceClient = + UserEventServiceClient.create(userEventServiceSettings); + } +} +// [END retail_v2beta_generated_usereventserviceclient_create_setendpoint_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEvents.java new file mode 100644 index 000000000000..441e4b8c0bca --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEvents.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_importuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.UserEventInputConfig; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncImportUserEvents { + + public static void main(String[] args) throws Exception { + asyncImportUserEvents(); + } + + public static void asyncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.importUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_importuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java new file mode 100644 index 000000000000..8b9a8a8af3d0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/AsyncImportUserEventsLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_importuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportMetadata; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.ImportUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventInputConfig; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncImportUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncImportUserEventsLRO(); + } + + public static void asyncImportUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + OperationFuture future = + userEventServiceClient.importUserEventsOperationCallable().futureCall(request); + // Do something. + ImportUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_importuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/SyncImportUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/SyncImportUserEvents.java new file mode 100644 index 000000000000..694c4f5b30ea --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/importuserevents/SyncImportUserEvents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_importuserevents_sync] +import com.google.cloud.retail.v2beta.CatalogName; +import com.google.cloud.retail.v2beta.ImportErrorsConfig; +import com.google.cloud.retail.v2beta.ImportUserEventsRequest; +import com.google.cloud.retail.v2beta.ImportUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventInputConfig; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncImportUserEvents { + + public static void main(String[] args) throws Exception { + syncImportUserEvents(); + } + + public static void syncImportUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + ImportUserEventsRequest request = + ImportUserEventsRequest.newBuilder() + .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) + .setInputConfig(UserEventInputConfig.newBuilder().build()) + .setErrorsConfig(ImportErrorsConfig.newBuilder().build()) + .build(); + ImportUserEventsResponse response = + userEventServiceClient.importUserEventsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_importuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java new file mode 100644 index 000000000000..2993e35541e5 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEvents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_purgeuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEvents(); + } + + public static void asyncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + ApiFuture future = + userEventServiceClient.purgeUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_purgeuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java new file mode 100644 index 000000000000..0c3327b1588f --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/AsyncPurgeUserEventsLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_purgeuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.PurgeMetadata; +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.PurgeUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncPurgeUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncPurgeUserEventsLRO(); + } + + public static void asyncPurgeUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + OperationFuture future = + userEventServiceClient.purgeUserEventsOperationCallable().futureCall(request); + // Do something. + PurgeUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_purgeuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java new file mode 100644 index 000000000000..a0beff6832a0 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/purgeuserevents/SyncPurgeUserEvents.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_purgeuserevents_sync] +import com.google.cloud.retail.v2beta.PurgeUserEventsRequest; +import com.google.cloud.retail.v2beta.PurgeUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncPurgeUserEvents { + + public static void main(String[] args) throws Exception { + syncPurgeUserEvents(); + } + + public static void syncPurgeUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + PurgeUserEventsRequest request = + PurgeUserEventsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setForce(true) + .build(); + PurgeUserEventsResponse response = userEventServiceClient.purgeUserEventsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_purgeuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java new file mode 100644 index 000000000000..0402ab4abf69 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEvents.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_rejoinuserevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.longrunning.Operation; + +public class AsyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEvents(); + } + + public static void asyncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + ApiFuture future = + userEventServiceClient.rejoinUserEventsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_rejoinuserevents_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java new file mode 100644 index 000000000000..fc843fc45d34 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/AsyncRejoinUserEventsLRO.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_rejoinuserevents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.retail.v2beta.RejoinUserEventsMetadata; +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.RejoinUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class AsyncRejoinUserEventsLRO { + + public static void main(String[] args) throws Exception { + asyncRejoinUserEventsLRO(); + } + + public static void asyncRejoinUserEventsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + OperationFuture future = + userEventServiceClient.rejoinUserEventsOperationCallable().futureCall(request); + // Do something. + RejoinUserEventsResponse response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_rejoinuserevents_lro_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java new file mode 100644 index 000000000000..6787f7bcb6f7 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/rejoinuserevents/SyncRejoinUserEvents.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_rejoinuserevents_sync] +import com.google.cloud.retail.v2beta.RejoinUserEventsRequest; +import com.google.cloud.retail.v2beta.RejoinUserEventsResponse; +import com.google.cloud.retail.v2beta.UserEventServiceClient; + +public class SyncRejoinUserEvents { + + public static void main(String[] args) throws Exception { + syncRejoinUserEvents(); + } + + public static void syncRejoinUserEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + RejoinUserEventsRequest request = + RejoinUserEventsRequest.newBuilder().setParent("parent-995424086").build(); + RejoinUserEventsResponse response = + userEventServiceClient.rejoinUserEventsAsync(request).get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_rejoinuserevents_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java new file mode 100644 index 000000000000..b4a1587aaa71 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/AsyncWriteUserEvent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_writeuserevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.WriteUserEventRequest; + +public class AsyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + asyncWriteUserEvent(); + } + + public static void asyncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + ApiFuture future = + userEventServiceClient.writeUserEventCallable().futureCall(request); + // Do something. + UserEvent response = future.get(); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_writeuserevent_async] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..789e7683297c --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventserviceclient/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventserviceclient_writeuserevent_sync] +import com.google.cloud.retail.v2beta.UserEvent; +import com.google.cloud.retail.v2beta.UserEventServiceClient; +import com.google.cloud.retail.v2beta.WriteUserEventRequest; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) { + WriteUserEventRequest request = + WriteUserEventRequest.newBuilder() + .setParent("parent-995424086") + .setUserEvent(UserEvent.newBuilder().build()) + .build(); + UserEvent response = userEventServiceClient.writeUserEvent(request); + } + } +} +// [END retail_v2beta_generated_usereventserviceclient_writeuserevent_sync] diff --git a/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java new file mode 100644 index 000000000000..a7c7a624c389 --- /dev/null +++ b/java-retail/samples/snippets/generated/com/google/cloud/retail/v2beta/usereventservicesettings/writeuserevent/SyncWriteUserEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.retail.v2beta.samples; + +// [START retail_v2beta_generated_usereventservicesettings_writeuserevent_sync] +import com.google.cloud.retail.v2beta.UserEventServiceSettings; +import java.time.Duration; + +public class SyncWriteUserEvent { + + public static void main(String[] args) throws Exception { + syncWriteUserEvent(); + } + + public static void syncWriteUserEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + UserEventServiceSettings.Builder userEventServiceSettingsBuilder = + UserEventServiceSettings.newBuilder(); + userEventServiceSettingsBuilder + .writeUserEventSettings() + .setRetrySettings( + userEventServiceSettingsBuilder + .writeUserEventSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + UserEventServiceSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); + } +} +// [END retail_v2beta_generated_usereventservicesettings_writeuserevent_sync]