From 42ffff768e445fc82c64a037fa346cb7d53864ba Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 18:46:15 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#1168) - [ ] 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 --- google-cloud-automl/pom.xml | 16 + .../google/cloud/automl/v1/AutoMlClient.java | 37 +- .../cloud/automl/v1/AutoMlSettings.java | 23 +- .../automl/v1/PredictionServiceClient.java | 38 +- .../automl/v1/PredictionServiceSettings.java | 23 +- .../cloud/automl/v1/stub/AutoMlStub.java | 6 +- .../automl/v1/stub/AutoMlStubSettings.java | 52 +- .../stub/HttpJsonAutoMlCallableFactory.java | 105 + .../automl/v1/stub/HttpJsonAutoMlStub.java | 1281 +++++++++ ...pJsonPredictionServiceCallableFactory.java | 105 + .../stub/HttpJsonPredictionServiceStub.java | 280 ++ .../automl/v1/stub/PredictionServiceStub.java | 6 +- .../stub/PredictionServiceStubSettings.java | 53 +- .../cloud/automl/v1beta1/AutoMlClient.java | 37 +- .../cloud/automl/v1beta1/AutoMlSettings.java | 23 +- .../v1beta1/PredictionServiceClient.java | 38 +- .../v1beta1/PredictionServiceSettings.java | 23 +- .../cloud/automl/v1beta1/stub/AutoMlStub.java | 6 +- .../v1beta1/stub/AutoMlStubSettings.java | 52 +- .../stub/HttpJsonAutoMlCallableFactory.java | 105 + .../v1beta1/stub/HttpJsonAutoMlStub.java | 1632 ++++++++++++ ...pJsonPredictionServiceCallableFactory.java | 105 + .../stub/HttpJsonPredictionServiceStub.java | 280 ++ .../v1beta1/stub/PredictionServiceStub.java | 6 +- .../stub/PredictionServiceStubSettings.java | 53 +- .../automl/v1/AutoMlClientHttpJsonTest.java | 1805 +++++++++++++ .../PredictionServiceClientHttpJsonTest.java | 287 ++ .../v1beta1/AutoMlClientHttpJsonTest.java | 2363 +++++++++++++++++ .../PredictionServiceClientHttpJsonTest.java | 287 ++ .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../createdataset/AsyncCreateDataset.java | 48 + .../createdataset/AsyncCreateDatasetLRO.java | 49 + .../createdataset/SyncCreateDataset.java | 44 + .../SyncCreateDatasetLocationnameDataset.java | 40 + .../SyncCreateDatasetStringDataset.java | 40 + .../createmodel/AsyncCreateModel.java | 48 + .../createmodel/AsyncCreateModelLRO.java | 49 + .../createmodel/SyncCreateModel.java | 44 + .../SyncCreateModelLocationnameModel.java | 40 + .../SyncCreateModelStringModel.java | 40 + .../deletedataset/AsyncDeleteDataset.java | 46 + .../deletedataset/AsyncDeleteDatasetLRO.java | 48 + .../deletedataset/SyncDeleteDataset.java | 43 + .../SyncDeleteDatasetDatasetname.java | 39 + .../SyncDeleteDatasetString.java | 39 + .../deletemodel/AsyncDeleteModel.java | 46 + .../deletemodel/AsyncDeleteModelLRO.java | 48 + .../deletemodel/SyncDeleteModel.java | 43 + .../deletemodel/SyncDeleteModelModelname.java | 39 + .../deletemodel/SyncDeleteModelString.java | 39 + .../deploymodel/AsyncDeployModel.java | 46 + .../deploymodel/AsyncDeployModelLRO.java | 48 + .../deploymodel/SyncDeployModel.java | 43 + .../deploymodel/SyncDeployModelModelname.java | 39 + .../deploymodel/SyncDeployModelString.java | 39 + .../exportdata/AsyncExportData.java | 48 + .../exportdata/AsyncExportDataLRO.java | 50 + .../exportdata/SyncExportData.java | 45 + ...SyncExportDataDatasetnameOutputconfig.java | 41 + .../SyncExportDataStringOutputconfig.java | 41 + .../exportmodel/AsyncExportModel.java | 48 + .../exportmodel/AsyncExportModelLRO.java | 50 + .../exportmodel/SyncExportModel.java | 45 + ...ModelModelnameModelexportoutputconfig.java | 41 + ...ortModelStringModelexportoutputconfig.java | 41 + .../AsyncGetAnnotationSpec.java | 49 + .../SyncGetAnnotationSpec.java | 45 + ...ncGetAnnotationSpecAnnotationspecname.java | 40 + .../SyncGetAnnotationSpecString.java | 41 + .../getdataset/AsyncGetDataset.java | 46 + .../getdataset/SyncGetDataset.java | 43 + .../getdataset/SyncGetDatasetDatasetname.java | 39 + .../getdataset/SyncGetDatasetString.java | 39 + .../automlclient/getmodel/AsyncGetModel.java | 46 + .../automlclient/getmodel/SyncGetModel.java | 43 + .../getmodel/SyncGetModelModelname.java | 39 + .../getmodel/SyncGetModelString.java | 39 + .../AsyncGetModelEvaluation.java | 49 + .../SyncGetModelEvaluation.java | 45 + ...GetModelEvaluationModelevaluationname.java | 40 + .../SyncGetModelEvaluationString.java | 41 + .../importdata/AsyncImportData.java | 48 + .../importdata/AsyncImportDataLRO.java | 50 + .../importdata/SyncImportData.java | 45 + .../SyncImportDataDatasetnameInputconfig.java | 41 + .../SyncImportDataStringInputconfig.java | 41 + .../listdatasets/AsyncListDatasets.java | 51 + .../listdatasets/AsyncListDatasetsPaged.java | 59 + .../listdatasets/SyncListDatasets.java | 48 + .../SyncListDatasetsLocationname.java | 41 + .../listdatasets/SyncListDatasetsString.java | 41 + .../AsyncListModelEvaluations.java | 52 + .../AsyncListModelEvaluationsPaged.java | 60 + .../SyncListModelEvaluations.java | 48 + ...ncListModelEvaluationsModelnameString.java | 43 + .../SyncListModelEvaluationsStringString.java | 43 + .../listmodels/AsyncListModels.java | 51 + .../listmodels/AsyncListModelsPaged.java | 59 + .../listmodels/SyncListModels.java | 48 + .../SyncListModelsLocationname.java | 41 + .../listmodels/SyncListModelsString.java | 41 + .../undeploymodel/AsyncUndeployModel.java | 46 + .../undeploymodel/AsyncUndeployModelLRO.java | 48 + .../undeploymodel/SyncUndeployModel.java | 43 + .../SyncUndeployModelModelname.java | 39 + .../SyncUndeployModelString.java | 39 + .../updatedataset/AsyncUpdateDataset.java | 47 + .../updatedataset/SyncUpdateDataset.java | 44 + .../SyncUpdateDatasetDatasetFieldmask.java | 40 + .../updatemodel/AsyncUpdateModel.java | 47 + .../updatemodel/SyncUpdateModel.java | 44 + .../SyncUpdateModelModelFieldmask.java | 40 + .../getdataset/SyncGetDataset.java | 45 + .../batchpredict/AsyncBatchPredict.java | 53 + .../batchpredict/AsyncBatchPredictLRO.java | 54 + .../batchpredict/SyncBatchPredict.java | 49 + ...tchpredictoutputconfigMapstringstring.java | 50 + ...tchpredictoutputconfigMapstringstring.java | 49 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../predict/AsyncPredict.java | 51 + .../predict/SyncPredict.java | 47 + ...odelnameExamplepayloadMapstringstring.java | 44 + ...ctStringExamplepayloadMapstringstring.java | 44 + .../predict/SyncPredict.java | 46 + .../getdataset/SyncGetDataset.java | 45 + .../predict/SyncPredict.java | 47 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../createdataset/AsyncCreateDataset.java | 47 + .../createdataset/SyncCreateDataset.java | 44 + .../SyncCreateDatasetLocationnameDataset.java | 40 + .../SyncCreateDatasetStringDataset.java | 40 + .../createmodel/AsyncCreateModel.java | 48 + .../createmodel/AsyncCreateModelLRO.java | 49 + .../createmodel/SyncCreateModel.java | 44 + .../SyncCreateModelLocationnameModel.java | 40 + .../SyncCreateModelStringModel.java | 40 + .../deletedataset/AsyncDeleteDataset.java | 46 + .../deletedataset/AsyncDeleteDatasetLRO.java | 48 + .../deletedataset/SyncDeleteDataset.java | 43 + .../SyncDeleteDatasetDatasetname.java | 39 + .../SyncDeleteDatasetString.java | 39 + .../deletemodel/AsyncDeleteModel.java | 46 + .../deletemodel/AsyncDeleteModelLRO.java | 48 + .../deletemodel/SyncDeleteModel.java | 43 + .../deletemodel/SyncDeleteModelModelname.java | 39 + .../deletemodel/SyncDeleteModelString.java | 39 + .../deploymodel/AsyncDeployModel.java | 46 + .../deploymodel/AsyncDeployModelLRO.java | 48 + .../deploymodel/SyncDeployModel.java | 43 + .../deploymodel/SyncDeployModelModelname.java | 39 + .../deploymodel/SyncDeployModelString.java | 39 + .../exportdata/AsyncExportData.java | 48 + .../exportdata/AsyncExportDataLRO.java | 50 + .../exportdata/SyncExportData.java | 45 + ...SyncExportDataDatasetnameOutputconfig.java | 41 + .../SyncExportDataStringOutputconfig.java | 41 + .../AsyncExportEvaluatedExamples.java | 49 + .../AsyncExportEvaluatedExamplesLRO.java | 50 + .../SyncExportEvaluatedExamples.java | 45 + ...meExportevaluatedexamplesoutputconfig.java | 43 + ...ngExportevaluatedexamplesoutputconfig.java | 43 + .../exportmodel/AsyncExportModel.java | 48 + .../exportmodel/AsyncExportModelLRO.java | 50 + .../exportmodel/SyncExportModel.java | 45 + ...ModelModelnameModelexportoutputconfig.java | 41 + ...ortModelStringModelexportoutputconfig.java | 41 + .../AsyncGetAnnotationSpec.java | 49 + .../SyncGetAnnotationSpec.java | 45 + ...ncGetAnnotationSpecAnnotationspecname.java | 40 + .../SyncGetAnnotationSpecString.java | 41 + .../getcolumnspec/AsyncGetColumnSpec.java | 51 + .../getcolumnspec/SyncGetColumnSpec.java | 48 + .../SyncGetColumnSpecColumnspecname.java | 41 + .../SyncGetColumnSpecString.java | 41 + .../getdataset/AsyncGetDataset.java | 46 + .../getdataset/SyncGetDataset.java | 43 + .../getdataset/SyncGetDatasetDatasetname.java | 39 + .../getdataset/SyncGetDatasetString.java | 39 + .../automlclient/getmodel/AsyncGetModel.java | 46 + .../automlclient/getmodel/SyncGetModel.java | 43 + .../getmodel/SyncGetModelModelname.java | 39 + .../getmodel/SyncGetModelString.java | 39 + .../AsyncGetModelEvaluation.java | 49 + .../SyncGetModelEvaluation.java | 45 + ...GetModelEvaluationModelevaluationname.java | 40 + .../SyncGetModelEvaluationString.java | 41 + .../gettablespec/AsyncGetTableSpec.java | 50 + .../gettablespec/SyncGetTableSpec.java | 47 + .../gettablespec/SyncGetTableSpecString.java | 40 + .../SyncGetTableSpecTablespecname.java | 39 + .../importdata/AsyncImportData.java | 48 + .../importdata/AsyncImportDataLRO.java | 50 + .../importdata/SyncImportData.java | 45 + .../SyncImportDataDatasetnameInputconfig.java | 41 + .../SyncImportDataStringInputconfig.java | 41 + .../listcolumnspecs/AsyncListColumnSpecs.java | 56 + .../AsyncListColumnSpecsPaged.java | 63 + .../listcolumnspecs/SyncListColumnSpecs.java | 52 + .../SyncListColumnSpecsString.java | 42 + .../SyncListColumnSpecsTablespecname.java | 42 + .../listdatasets/AsyncListDatasets.java | 51 + .../listdatasets/AsyncListDatasetsPaged.java | 59 + .../listdatasets/SyncListDatasets.java | 48 + .../SyncListDatasetsLocationname.java | 41 + .../listdatasets/SyncListDatasetsString.java | 41 + .../AsyncListModelEvaluations.java | 52 + .../AsyncListModelEvaluationsPaged.java | 60 + .../SyncListModelEvaluations.java | 48 + .../SyncListModelEvaluationsModelname.java | 41 + .../SyncListModelEvaluationsString.java | 41 + .../listmodels/AsyncListModels.java | 51 + .../listmodels/AsyncListModelsPaged.java | 59 + .../listmodels/SyncListModels.java | 48 + .../SyncListModelsLocationname.java | 41 + .../listmodels/SyncListModelsString.java | 41 + .../listtablespecs/AsyncListTableSpecs.java | 53 + .../AsyncListTableSpecsPaged.java | 61 + .../listtablespecs/SyncListTableSpecs.java | 50 + .../SyncListTableSpecsDatasetname.java | 41 + .../SyncListTableSpecsString.java | 41 + .../undeploymodel/AsyncUndeployModel.java | 46 + .../undeploymodel/AsyncUndeployModelLRO.java | 48 + .../undeploymodel/SyncUndeployModel.java | 43 + .../SyncUndeployModelModelname.java | 39 + .../SyncUndeployModelString.java | 39 + .../AsyncUpdateColumnSpec.java | 47 + .../SyncUpdateColumnSpec.java | 44 + .../SyncUpdateColumnSpecColumnspec.java | 38 + .../updatedataset/AsyncUpdateDataset.java | 47 + .../updatedataset/SyncUpdateDataset.java | 44 + .../SyncUpdateDatasetDataset.java | 38 + .../updatetablespec/AsyncUpdateTableSpec.java | 47 + .../updatetablespec/SyncUpdateTableSpec.java | 44 + .../SyncUpdateTableSpecTablespec.java | 38 + .../createdataset/SyncCreateDataset.java | 45 + .../batchpredict/AsyncBatchPredict.java | 53 + .../batchpredict/AsyncBatchPredictLRO.java | 54 + .../batchpredict/SyncBatchPredict.java | 49 + ...tchpredictoutputconfigMapstringstring.java | 50 + ...tchpredictoutputconfigMapstringstring.java | 49 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../predict/AsyncPredict.java | 51 + .../predict/SyncPredict.java | 47 + ...odelnameExamplepayloadMapstringstring.java | 44 + ...ctStringExamplepayloadMapstringstring.java | 44 + .../predict/SyncPredict.java | 46 + .../createdataset/SyncCreateDataset.java | 45 + .../predict/SyncPredict.java | 47 + 256 files changed, 19268 insertions(+), 44 deletions(-) create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlCallableFactory.java create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlStub.java create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonPredictionServiceCallableFactory.java create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonPredictionServiceStub.java create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlCallableFactory.java create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlStub.java create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonPredictionServiceCallableFactory.java create mode 100644 google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonPredictionServiceStub.java create mode 100644 google-cloud-automl/src/test/java/com/google/cloud/automl/v1/AutoMlClientHttpJsonTest.java create mode 100644 google-cloud-automl/src/test/java/com/google/cloud/automl/v1/PredictionServiceClientHttpJsonTest.java create mode 100644 google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/AutoMlClientHttpJsonTest.java create mode 100644 google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/PredictionServiceClientHttpJsonTest.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDatasetLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetStringDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelLocationnameModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelStringModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDatasetLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportDataLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataStringOutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/AsyncGetAnnotationSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/AsyncGetDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetDatasetname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/AsyncGetModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluation.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportDataLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataStringInputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasets.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasetsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasets.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluations.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluations.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelnameString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModels.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModelsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModels.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/AsyncUpdateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDatasetDatasetFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/AsyncUpdateModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModelModelFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/automlsettings/getdataset/SyncGetDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/AsyncPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/predictionservicesettings/predict/SyncPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/stub/automlstubsettings/getdataset/SyncGetDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1/stub/predictionservicestubsettings/predict/SyncPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/AsyncCreateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetStringDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelLocationnameModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelStringModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDatasetLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportDataLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataStringOutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamples.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamplesLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamples.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesModelnameExportevaluatedexamplesoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesStringExportevaluatedexamplesoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/AsyncGetAnnotationSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/AsyncGetColumnSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecColumnspecname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/AsyncGetDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetDatasetname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/AsyncGetModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluation.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/AsyncGetTableSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecTablespecname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportDataLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportData.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataStringInputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecs.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecs.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsTablespecname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasets.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasetsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasets.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluations.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluations.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModels.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModelsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModels.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecs.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecs.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsDatasetname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModelLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModel.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelModelname.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelString.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/AsyncUpdateColumnSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpecColumnspec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/AsyncUpdateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDatasetDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/AsyncUpdateTableSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpecTablespec.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/automlsettings/createdataset/SyncCreateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/AsyncPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionservicesettings/predict/SyncPredict.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/stub/automlstubsettings/createdataset/SyncCreateDataset.java create mode 100644 samples/snippets/generated/com/google/cloud/automl/v1beta1/stub/predictionservicestubsettings/predict/SyncPredict.java diff --git a/google-cloud-automl/pom.xml b/google-cloud-automl/pom.xml index c7e519300..8feebc519 100644 --- a/google-cloud-automl/pom.xml +++ b/google-cloud-automl/pom.xml @@ -62,6 +62,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -85,12 +89,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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.java index fcebb2600..54ea22982 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.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.automl.v1.stub.AutoMlStubSettings; 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; @@ -113,13 +113,28 @@ * AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); * } * + *

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.
+ * AutoMlSettings autoMlSettings =
+ *     AutoMlSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AutoMlSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class AutoMlClient implements BackgroundResource { private final AutoMlSettings settings; private final AutoMlStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of AutoMlClient with default settings. */ public static final AutoMlClient create() throws IOException { @@ -149,13 +164,17 @@ public static final AutoMlClient create(AutoMlStub stub) { protected AutoMlClient(AutoMlSettings settings) throws IOException { this.settings = settings; this.stub = ((AutoMlStubSettings) 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 AutoMlClient(AutoMlStub 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 AutoMlSettings getSettings() { @@ -170,10 +189,18 @@ public AutoMlStub 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 dataset. diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java index ce8f3a4cb..e2ad1e9eb 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java @@ -25,6 +25,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; @@ -250,11 +251,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AutoMlStubSettings.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 AutoMlStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AutoMlStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AutoMlStubSettings.defaultTransportChannelProvider(); } @@ -264,11 +272,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AutoMlStubSettings.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); @@ -306,6 +320,11 @@ private static Builder createDefault() { return new Builder(AutoMlStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AutoMlStubSettings.newHttpJsonBuilder()); + } + public AutoMlStubSettings.Builder getStubSettingsBuilder() { return ((AutoMlStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java index b3032e530..395ba9116 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java @@ -17,13 +17,13 @@ package com.google.cloud.automl.v1; 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.automl.v1.stub.PredictionServiceStub; import com.google.cloud.automl.v1.stub.PredictionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -101,13 +101,29 @@ * 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") public class PredictionServiceClient implements BackgroundResource { private final PredictionServiceSettings settings; private final PredictionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of PredictionServiceClient with default settings. */ public static final PredictionServiceClient create() throws IOException { @@ -139,13 +155,17 @@ public static final PredictionServiceClient create(PredictionServiceStub stub) { protected PredictionServiceClient(PredictionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((PredictionServiceStubSettings) 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 PredictionServiceClient(PredictionServiceStub 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 PredictionServiceSettings getSettings() { @@ -160,10 +180,18 @@ public PredictionServiceStub 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. /** * Perform an online prediction. The prediction result is directly returned in the response. diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceSettings.java index 140a27c74..30502b271 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/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; @@ -111,11 +112,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(); } @@ -125,11 +133,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); @@ -167,6 +181,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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java index 7382172f4..0b72d45fb 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java @@ -64,7 +64,11 @@ public abstract class AutoMlStub 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 OperationCallable diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java index 06996c634..a40656381 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java @@ -30,6 +30,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; @@ -496,6 +499,11 @@ public AutoMlStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAutoMlStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAutoMlStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -528,29 +536,54 @@ 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(AutoMlStubSettings.class)) .setTransportToken( 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(AutoMlStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AutoMlStubSettings.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); @@ -810,6 +843,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 .createDatasetSettings() diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlCallableFactory.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlCallableFactory.java new file mode 100644 index 000000000..7b109379d --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlCallableFactory.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.automl.v1.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 AutoMl service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAutoMlCallableFactory + 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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlStub.java new file mode 100644 index 000000000..8eecc6b64 --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlStub.java @@ -0,0 +1,1281 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1.stub; + +import static com.google.cloud.automl.v1.AutoMlClient.ListDatasetsPagedResponse; +import static com.google.cloud.automl.v1.AutoMlClient.ListModelEvaluationsPagedResponse; +import static com.google.cloud.automl.v1.AutoMlClient.ListModelsPagedResponse; + +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.automl.v1.AnnotationSpec; +import com.google.cloud.automl.v1.CreateDatasetRequest; +import com.google.cloud.automl.v1.CreateModelRequest; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.DeleteDatasetRequest; +import com.google.cloud.automl.v1.DeleteModelRequest; +import com.google.cloud.automl.v1.DeployModelRequest; +import com.google.cloud.automl.v1.ExportDataRequest; +import com.google.cloud.automl.v1.ExportModelRequest; +import com.google.cloud.automl.v1.GetAnnotationSpecRequest; +import com.google.cloud.automl.v1.GetDatasetRequest; +import com.google.cloud.automl.v1.GetModelEvaluationRequest; +import com.google.cloud.automl.v1.GetModelRequest; +import com.google.cloud.automl.v1.ImportDataRequest; +import com.google.cloud.automl.v1.ListDatasetsRequest; +import com.google.cloud.automl.v1.ListDatasetsResponse; +import com.google.cloud.automl.v1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1.ListModelEvaluationsResponse; +import com.google.cloud.automl.v1.ListModelsRequest; +import com.google.cloud.automl.v1.ListModelsResponse; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.cloud.automl.v1.UndeployModelRequest; +import com.google.cloud.automl.v1.UpdateDatasetRequest; +import com.google.cloud.automl.v1.UpdateModelRequest; +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 AutoMl service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAutoMlStub extends AutoMlStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Dataset.getDescriptor()) + .add(Empty.getDescriptor()) + .add(Model.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/CreateDataset") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/datasets", + 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("dataset", request.getDataset())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateDatasetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor getDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/GetDataset") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/datasets/*}", + 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(Dataset.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDatasetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/ListDatasets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/datasets", + 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(ListDatasetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/UpdateDataset") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{dataset.name=projects/*/locations/*/datasets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "dataset.name", request.getDataset().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("dataset", request.getDataset())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Dataset.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/DeleteDataset") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/datasets/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteDatasetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/ImportData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/datasets/*}:importData", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/ExportData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/datasets/*}:exportData", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getAnnotationSpecMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/GetAnnotationSpec") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/datasets/*/annotationSpecs/*}", + 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(AnnotationSpec.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/CreateModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/models", + 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("model", request.getModel())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor getModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/GetModel") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*}", + 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(Model.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listModelsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/ListModels") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/models", + 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(ListModelsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/DeleteModel") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor updateModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/UpdateModel") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{model.name=projects/*/locations/*/models/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "model.name", request.getModel().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("model", request.getModel())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Model.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deployModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/DeployModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*}:deploy", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeployModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + undeployModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/UndeployModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*}:undeploy", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UndeployModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/ExportModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*}:export", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getModelEvaluationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/GetModelEvaluation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*/modelEvaluations/*}", + 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(ModelEvaluation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListModelEvaluationsRequest, ListModelEvaluationsResponse> + listModelEvaluationsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.automl.v1.AutoMl/ListModelEvaluations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/models/*}/modelEvaluations", + 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(ListModelEvaluationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createDatasetCallable; + private final OperationCallable + createDatasetOperationCallable; + private final UnaryCallable getDatasetCallable; + private final UnaryCallable listDatasetsCallable; + private final UnaryCallable + listDatasetsPagedCallable; + private final UnaryCallable updateDatasetCallable; + private final UnaryCallable deleteDatasetCallable; + private final OperationCallable + deleteDatasetOperationCallable; + private final UnaryCallable importDataCallable; + private final OperationCallable + importDataOperationCallable; + private final UnaryCallable exportDataCallable; + private final OperationCallable + exportDataOperationCallable; + private final UnaryCallable getAnnotationSpecCallable; + private final UnaryCallable createModelCallable; + private final OperationCallable + createModelOperationCallable; + private final UnaryCallable getModelCallable; + private final UnaryCallable listModelsCallable; + private final UnaryCallable listModelsPagedCallable; + private final UnaryCallable deleteModelCallable; + private final OperationCallable + deleteModelOperationCallable; + private final UnaryCallable updateModelCallable; + private final UnaryCallable deployModelCallable; + private final OperationCallable + deployModelOperationCallable; + private final UnaryCallable undeployModelCallable; + private final OperationCallable + undeployModelOperationCallable; + private final UnaryCallable exportModelCallable; + private final OperationCallable + exportModelOperationCallable; + private final UnaryCallable + getModelEvaluationCallable; + private final UnaryCallable + listModelEvaluationsCallable; + private final UnaryCallable + listModelEvaluationsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAutoMlStub create(AutoMlStubSettings settings) throws IOException { + return new HttpJsonAutoMlStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAutoMlStub create(ClientContext clientContext) throws IOException { + return new HttpJsonAutoMlStub(AutoMlStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAutoMlStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAutoMlStub( + AutoMlStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonAutoMlStub, 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 HttpJsonAutoMlStub(AutoMlStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonAutoMlCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAutoMlStub, 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 HttpJsonAutoMlStub( + AutoMlStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listDatasetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDatasetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getAnnotationSpecTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAnnotationSpecMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listModelsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listModelsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deployModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deployModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings undeployModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(undeployModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getModelEvaluationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getModelEvaluationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listModelEvaluationsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listModelEvaluationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createDatasetCallable = + callableFactory.createUnaryCallable( + createDatasetTransportSettings, settings.createDatasetSettings(), clientContext); + this.createDatasetOperationCallable = + callableFactory.createOperationCallable( + createDatasetTransportSettings, + settings.createDatasetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getDatasetCallable = + callableFactory.createUnaryCallable( + getDatasetTransportSettings, settings.getDatasetSettings(), clientContext); + this.listDatasetsCallable = + callableFactory.createUnaryCallable( + listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext); + this.listDatasetsPagedCallable = + callableFactory.createPagedCallable( + listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext); + this.updateDatasetCallable = + callableFactory.createUnaryCallable( + updateDatasetTransportSettings, settings.updateDatasetSettings(), clientContext); + this.deleteDatasetCallable = + callableFactory.createUnaryCallable( + deleteDatasetTransportSettings, settings.deleteDatasetSettings(), clientContext); + this.deleteDatasetOperationCallable = + callableFactory.createOperationCallable( + deleteDatasetTransportSettings, + settings.deleteDatasetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importDataCallable = + callableFactory.createUnaryCallable( + importDataTransportSettings, settings.importDataSettings(), clientContext); + this.importDataOperationCallable = + callableFactory.createOperationCallable( + importDataTransportSettings, + settings.importDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.exportDataCallable = + callableFactory.createUnaryCallable( + exportDataTransportSettings, settings.exportDataSettings(), clientContext); + this.exportDataOperationCallable = + callableFactory.createOperationCallable( + exportDataTransportSettings, + settings.exportDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getAnnotationSpecCallable = + callableFactory.createUnaryCallable( + getAnnotationSpecTransportSettings, + settings.getAnnotationSpecSettings(), + clientContext); + this.createModelCallable = + callableFactory.createUnaryCallable( + createModelTransportSettings, settings.createModelSettings(), clientContext); + this.createModelOperationCallable = + callableFactory.createOperationCallable( + createModelTransportSettings, + settings.createModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getModelCallable = + callableFactory.createUnaryCallable( + getModelTransportSettings, settings.getModelSettings(), clientContext); + this.listModelsCallable = + callableFactory.createUnaryCallable( + listModelsTransportSettings, settings.listModelsSettings(), clientContext); + this.listModelsPagedCallable = + callableFactory.createPagedCallable( + listModelsTransportSettings, settings.listModelsSettings(), clientContext); + this.deleteModelCallable = + callableFactory.createUnaryCallable( + deleteModelTransportSettings, settings.deleteModelSettings(), clientContext); + this.deleteModelOperationCallable = + callableFactory.createOperationCallable( + deleteModelTransportSettings, + settings.deleteModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateModelCallable = + callableFactory.createUnaryCallable( + updateModelTransportSettings, settings.updateModelSettings(), clientContext); + this.deployModelCallable = + callableFactory.createUnaryCallable( + deployModelTransportSettings, settings.deployModelSettings(), clientContext); + this.deployModelOperationCallable = + callableFactory.createOperationCallable( + deployModelTransportSettings, + settings.deployModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.undeployModelCallable = + callableFactory.createUnaryCallable( + undeployModelTransportSettings, settings.undeployModelSettings(), clientContext); + this.undeployModelOperationCallable = + callableFactory.createOperationCallable( + undeployModelTransportSettings, + settings.undeployModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.exportModelCallable = + callableFactory.createUnaryCallable( + exportModelTransportSettings, settings.exportModelSettings(), clientContext); + this.exportModelOperationCallable = + callableFactory.createOperationCallable( + exportModelTransportSettings, + settings.exportModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getModelEvaluationCallable = + callableFactory.createUnaryCallable( + getModelEvaluationTransportSettings, + settings.getModelEvaluationSettings(), + clientContext); + this.listModelEvaluationsCallable = + callableFactory.createUnaryCallable( + listModelEvaluationsTransportSettings, + settings.listModelEvaluationsSettings(), + clientContext); + this.listModelEvaluationsPagedCallable = + callableFactory.createPagedCallable( + listModelEvaluationsTransportSettings, + settings.listModelEvaluationsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createDatasetMethodDescriptor); + methodDescriptors.add(getDatasetMethodDescriptor); + methodDescriptors.add(listDatasetsMethodDescriptor); + methodDescriptors.add(updateDatasetMethodDescriptor); + methodDescriptors.add(deleteDatasetMethodDescriptor); + methodDescriptors.add(importDataMethodDescriptor); + methodDescriptors.add(exportDataMethodDescriptor); + methodDescriptors.add(getAnnotationSpecMethodDescriptor); + methodDescriptors.add(createModelMethodDescriptor); + methodDescriptors.add(getModelMethodDescriptor); + methodDescriptors.add(listModelsMethodDescriptor); + methodDescriptors.add(deleteModelMethodDescriptor); + methodDescriptors.add(updateModelMethodDescriptor); + methodDescriptors.add(deployModelMethodDescriptor); + methodDescriptors.add(undeployModelMethodDescriptor); + methodDescriptors.add(exportModelMethodDescriptor); + methodDescriptors.add(getModelEvaluationMethodDescriptor); + methodDescriptors.add(listModelEvaluationsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createDatasetCallable() { + return createDatasetCallable; + } + + @Override + public OperationCallable + createDatasetOperationCallable() { + return createDatasetOperationCallable; + } + + @Override + public UnaryCallable getDatasetCallable() { + return getDatasetCallable; + } + + @Override + public UnaryCallable listDatasetsCallable() { + return listDatasetsCallable; + } + + @Override + public UnaryCallable listDatasetsPagedCallable() { + return listDatasetsPagedCallable; + } + + @Override + public UnaryCallable updateDatasetCallable() { + return updateDatasetCallable; + } + + @Override + public UnaryCallable deleteDatasetCallable() { + return deleteDatasetCallable; + } + + @Override + public OperationCallable + deleteDatasetOperationCallable() { + return deleteDatasetOperationCallable; + } + + @Override + public UnaryCallable importDataCallable() { + return importDataCallable; + } + + @Override + public OperationCallable + importDataOperationCallable() { + return importDataOperationCallable; + } + + @Override + public UnaryCallable exportDataCallable() { + return exportDataCallable; + } + + @Override + public OperationCallable + exportDataOperationCallable() { + return exportDataOperationCallable; + } + + @Override + public UnaryCallable getAnnotationSpecCallable() { + return getAnnotationSpecCallable; + } + + @Override + public UnaryCallable createModelCallable() { + return createModelCallable; + } + + @Override + public OperationCallable + createModelOperationCallable() { + return createModelOperationCallable; + } + + @Override + public UnaryCallable getModelCallable() { + return getModelCallable; + } + + @Override + public UnaryCallable listModelsCallable() { + return listModelsCallable; + } + + @Override + public UnaryCallable listModelsPagedCallable() { + return listModelsPagedCallable; + } + + @Override + public UnaryCallable deleteModelCallable() { + return deleteModelCallable; + } + + @Override + public OperationCallable + deleteModelOperationCallable() { + return deleteModelOperationCallable; + } + + @Override + public UnaryCallable updateModelCallable() { + return updateModelCallable; + } + + @Override + public UnaryCallable deployModelCallable() { + return deployModelCallable; + } + + @Override + public OperationCallable + deployModelOperationCallable() { + return deployModelOperationCallable; + } + + @Override + public UnaryCallable undeployModelCallable() { + return undeployModelCallable; + } + + @Override + public OperationCallable + undeployModelOperationCallable() { + return undeployModelOperationCallable; + } + + @Override + public UnaryCallable exportModelCallable() { + return exportModelCallable; + } + + @Override + public OperationCallable + exportModelOperationCallable() { + return exportModelOperationCallable; + } + + @Override + public UnaryCallable getModelEvaluationCallable() { + return getModelEvaluationCallable; + } + + @Override + public UnaryCallable + listModelEvaluationsCallable() { + return listModelEvaluationsCallable; + } + + @Override + public UnaryCallable + listModelEvaluationsPagedCallable() { + return listModelEvaluationsPagedCallable; + } + + @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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonPredictionServiceCallableFactory.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 000000000..3f213e460 --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/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.automl.v1.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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonPredictionServiceStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 000000000..e56dc4449 --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,280 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1.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.automl.v1.BatchPredictRequest; +import com.google.cloud.automl.v1.BatchPredictResult; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.cloud.automl.v1.PredictRequest; +import com.google.cloud.automl.v1.PredictResponse; +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 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() + .add(BatchPredictResult.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*}:predict", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchPredictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1.PredictionService/BatchPredict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/models/*}:batchPredict", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchPredictRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable predictCallable; + private final UnaryCallable batchPredictCallable; + private final OperationCallable + batchPredictOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + 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; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchPredictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchPredictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + this.batchPredictCallable = + callableFactory.createUnaryCallable( + batchPredictTransportSettings, settings.batchPredictSettings(), clientContext); + this.batchPredictOperationCallable = + callableFactory.createOperationCallable( + batchPredictTransportSettings, + settings.batchPredictOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + methodDescriptors.add(batchPredictMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @Override + public UnaryCallable batchPredictCallable() { + return batchPredictCallable; + } + + @Override + public OperationCallable + batchPredictOperationCallable() { + return batchPredictOperationCallable; + } + + @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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStub.java index c2504226a..0ad432731 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStub.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStub.java @@ -38,7 +38,11 @@ public abstract class PredictionServiceStub 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 predictCallable() { diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStubSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStubSettings.java index f959d9228..4b992e961 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStubSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/PredictionServiceStubSettings.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; @@ -118,6 +121,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())); @@ -150,18 +158,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)) @@ -169,11 +184,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); @@ -267,6 +301,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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlClient.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlClient.java index d56dcc48c..5aa8147a6 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlClient.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlClient.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.automl.v1beta1.stub.AutoMlStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -114,6 +114,20 @@ * AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); * } * + *

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.
+ * AutoMlSettings autoMlSettings =
+ *     AutoMlSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AutoMlSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -121,7 +135,8 @@ public class AutoMlClient implements BackgroundResource { private final AutoMlSettings settings; private final AutoMlStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of AutoMlClient with default settings. */ public static final AutoMlClient create() throws IOException { @@ -151,13 +166,17 @@ public static final AutoMlClient create(AutoMlStub stub) { protected AutoMlClient(AutoMlSettings settings) throws IOException { this.settings = settings; this.stub = ((AutoMlStubSettings) 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 AutoMlClient(AutoMlStub 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 AutoMlSettings getSettings() { @@ -172,10 +191,18 @@ public AutoMlStub 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 dataset. diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlSettings.java index 89a983100..17c48978f 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/AutoMlSettings.java @@ -27,6 +27,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; @@ -288,11 +289,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AutoMlStubSettings.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 AutoMlStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AutoMlStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AutoMlStubSettings.defaultTransportChannelProvider(); } @@ -302,11 +310,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AutoMlStubSettings.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); @@ -344,6 +358,11 @@ private static Builder createDefault() { return new Builder(AutoMlStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AutoMlStubSettings.newHttpJsonBuilder()); + } + public AutoMlStubSettings.Builder getStubSettingsBuilder() { return ((AutoMlStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/PredictionServiceClient.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/PredictionServiceClient.java index b99f4de1a..addafbdb8 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/PredictionServiceClient.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/PredictionServiceClient.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.automl.v1beta1.stub.PredictionServiceStub; import com.google.cloud.automl.v1beta1.stub.PredictionServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -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 @@ -109,7 +124,8 @@ public class PredictionServiceClient implements BackgroundResource { private final PredictionServiceSettings settings; private final PredictionServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of PredictionServiceClient with default settings. */ public static final PredictionServiceClient create() throws IOException { @@ -141,13 +157,17 @@ public static final PredictionServiceClient create(PredictionServiceStub stub) { protected PredictionServiceClient(PredictionServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((PredictionServiceStubSettings) 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 PredictionServiceClient(PredictionServiceStub 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 PredictionServiceSettings getSettings() { @@ -162,10 +182,18 @@ public PredictionServiceStub 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. /** * Perform an online prediction. The prediction result will be directly returned in the response. diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/PredictionServiceSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/PredictionServiceSettings.java index 4657c21f2..500bd9ec0 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/PredictionServiceSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/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; @@ -112,11 +113,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(); } @@ -126,11 +134,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); @@ -168,6 +182,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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStub.java index d2e969c4a..56378c9a5 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStub.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStub.java @@ -78,7 +78,11 @@ public abstract class AutoMlStub 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 createDatasetCallable() { diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStubSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStubSettings.java index c84c2772e..9f74c67bd 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStubSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/AutoMlStubSettings.java @@ -32,6 +32,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; @@ -665,6 +668,11 @@ public AutoMlStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAutoMlStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAutoMlStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -697,29 +705,54 @@ 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(AutoMlStubSettings.class)) .setTransportToken( 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(AutoMlStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AutoMlStubSettings.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); @@ -1025,6 +1058,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 .createDatasetSettings() diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlCallableFactory.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlCallableFactory.java new file mode 100644 index 000000000..9723bf7c6 --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlCallableFactory.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.automl.v1beta1.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 AutoMl service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonAutoMlCallableFactory + 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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlStub.java new file mode 100644 index 000000000..d5ceb86e1 --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonAutoMlStub.java @@ -0,0 +1,1632 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1beta1.stub; + +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListColumnSpecsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListDatasetsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListModelEvaluationsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListTableSpecsPagedResponse; + +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.automl.v1beta1.AnnotationSpec; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.CreateDatasetRequest; +import com.google.cloud.automl.v1beta1.CreateModelRequest; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.DeleteDatasetRequest; +import com.google.cloud.automl.v1beta1.DeleteModelRequest; +import com.google.cloud.automl.v1beta1.DeployModelRequest; +import com.google.cloud.automl.v1beta1.ExportDataRequest; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesRequest; +import com.google.cloud.automl.v1beta1.ExportModelRequest; +import com.google.cloud.automl.v1beta1.GetAnnotationSpecRequest; +import com.google.cloud.automl.v1beta1.GetColumnSpecRequest; +import com.google.cloud.automl.v1beta1.GetDatasetRequest; +import com.google.cloud.automl.v1beta1.GetModelEvaluationRequest; +import com.google.cloud.automl.v1beta1.GetModelRequest; +import com.google.cloud.automl.v1beta1.GetTableSpecRequest; +import com.google.cloud.automl.v1beta1.ImportDataRequest; +import com.google.cloud.automl.v1beta1.ListColumnSpecsRequest; +import com.google.cloud.automl.v1beta1.ListColumnSpecsResponse; +import com.google.cloud.automl.v1beta1.ListDatasetsRequest; +import com.google.cloud.automl.v1beta1.ListDatasetsResponse; +import com.google.cloud.automl.v1beta1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1beta1.ListModelEvaluationsResponse; +import com.google.cloud.automl.v1beta1.ListModelsRequest; +import com.google.cloud.automl.v1beta1.ListModelsResponse; +import com.google.cloud.automl.v1beta1.ListTableSpecsRequest; +import com.google.cloud.automl.v1beta1.ListTableSpecsResponse; +import com.google.cloud.automl.v1beta1.Model; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.cloud.automl.v1beta1.UndeployModelRequest; +import com.google.cloud.automl.v1beta1.UpdateColumnSpecRequest; +import com.google.cloud.automl.v1beta1.UpdateDatasetRequest; +import com.google.cloud.automl.v1beta1.UpdateTableSpecRequest; +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 AutoMl service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonAutoMlStub extends AutoMlStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(Model.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/CreateDataset") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/datasets", + 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("dataset", request.getDataset())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Dataset.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/GetDataset") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/datasets/*}", + 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(Dataset.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDatasetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ListDatasets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/datasets", + 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(ListDatasetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/UpdateDataset") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{dataset.name=projects/*/locations/*/datasets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "dataset.name", request.getDataset().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("dataset", request.getDataset())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Dataset.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/DeleteDataset") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/datasets/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteDatasetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ImportData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/datasets/*}:importData", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ExportData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/datasets/*}:exportData", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getAnnotationSpecMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/GetAnnotationSpec") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/datasets/*/annotationSpecs/*}", + 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(AnnotationSpec.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getTableSpecMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/GetTableSpec") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/datasets/*/tableSpecs/*}", + 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(); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TableSpec.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listTableSpecsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ListTableSpecs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/datasets/*}/tableSpecs", + 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, "fieldMask", request.getFieldMask()); + 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(ListTableSpecsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateTableSpecMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/UpdateTableSpec") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{tableSpec.name=projects/*/locations/*/datasets/*/tableSpecs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "tableSpec.name", request.getTableSpec().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("tableSpec", request.getTableSpec())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TableSpec.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getColumnSpecMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/GetColumnSpec") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/datasets/*/tableSpecs/*/columnSpecs/*}", + 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(); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ColumnSpec.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listColumnSpecsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ListColumnSpecs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/datasets/*/tableSpecs/*}/columnSpecs", + 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, "fieldMask", request.getFieldMask()); + 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(ListColumnSpecsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateColumnSpecMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/UpdateColumnSpec") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{columnSpec.name=projects/*/locations/*/datasets/*/tableSpecs/*/columnSpecs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "columnSpec.name", request.getColumnSpec().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("columnSpec", request.getColumnSpec())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ColumnSpec.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/CreateModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/models", + 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("model", request.getModel())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor getModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/GetModel") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}", + 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(Model.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listModelsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ListModels") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/models", + 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(ListModelsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/DeleteModel") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deployModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/DeployModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}:deploy", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeployModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + undeployModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/UndeployModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}:undeploy", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UndeployModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ExportModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}:export", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportEvaluatedExamplesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ExportEvaluatedExamples") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}:exportEvaluatedExamples", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportEvaluatedExamplesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getModelEvaluationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/GetModelEvaluation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*/modelEvaluations/*}", + 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(ModelEvaluation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListModelEvaluationsRequest, ListModelEvaluationsResponse> + listModelEvaluationsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.AutoMl/ListModelEvaluations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/models/*}/modelEvaluations", + 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(ListModelEvaluationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createDatasetCallable; + private final UnaryCallable getDatasetCallable; + private final UnaryCallable listDatasetsCallable; + private final UnaryCallable + listDatasetsPagedCallable; + private final UnaryCallable updateDatasetCallable; + private final UnaryCallable deleteDatasetCallable; + private final OperationCallable + deleteDatasetOperationCallable; + private final UnaryCallable importDataCallable; + private final OperationCallable + importDataOperationCallable; + private final UnaryCallable exportDataCallable; + private final OperationCallable + exportDataOperationCallable; + private final UnaryCallable getAnnotationSpecCallable; + private final UnaryCallable getTableSpecCallable; + private final UnaryCallable listTableSpecsCallable; + private final UnaryCallable + listTableSpecsPagedCallable; + private final UnaryCallable updateTableSpecCallable; + private final UnaryCallable getColumnSpecCallable; + private final UnaryCallable + listColumnSpecsCallable; + private final UnaryCallable + listColumnSpecsPagedCallable; + private final UnaryCallable updateColumnSpecCallable; + private final UnaryCallable createModelCallable; + private final OperationCallable + createModelOperationCallable; + private final UnaryCallable getModelCallable; + private final UnaryCallable listModelsCallable; + private final UnaryCallable listModelsPagedCallable; + private final UnaryCallable deleteModelCallable; + private final OperationCallable + deleteModelOperationCallable; + private final UnaryCallable deployModelCallable; + private final OperationCallable + deployModelOperationCallable; + private final UnaryCallable undeployModelCallable; + private final OperationCallable + undeployModelOperationCallable; + private final UnaryCallable exportModelCallable; + private final OperationCallable + exportModelOperationCallable; + private final UnaryCallable + exportEvaluatedExamplesCallable; + private final OperationCallable + exportEvaluatedExamplesOperationCallable; + private final UnaryCallable + getModelEvaluationCallable; + private final UnaryCallable + listModelEvaluationsCallable; + private final UnaryCallable + listModelEvaluationsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAutoMlStub create(AutoMlStubSettings settings) throws IOException { + return new HttpJsonAutoMlStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAutoMlStub create(ClientContext clientContext) throws IOException { + return new HttpJsonAutoMlStub(AutoMlStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAutoMlStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAutoMlStub( + AutoMlStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonAutoMlStub, 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 HttpJsonAutoMlStub(AutoMlStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonAutoMlCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAutoMlStub, 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 HttpJsonAutoMlStub( + AutoMlStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listDatasetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDatasetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getAnnotationSpecTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAnnotationSpecMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getTableSpecTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getTableSpecMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listTableSpecsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listTableSpecsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateTableSpecTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateTableSpecMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getColumnSpecTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getColumnSpecMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listColumnSpecsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listColumnSpecsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateColumnSpecTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateColumnSpecMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listModelsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listModelsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deployModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deployModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings undeployModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(undeployModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + exportEvaluatedExamplesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportEvaluatedExamplesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getModelEvaluationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getModelEvaluationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listModelEvaluationsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listModelEvaluationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createDatasetCallable = + callableFactory.createUnaryCallable( + createDatasetTransportSettings, settings.createDatasetSettings(), clientContext); + this.getDatasetCallable = + callableFactory.createUnaryCallable( + getDatasetTransportSettings, settings.getDatasetSettings(), clientContext); + this.listDatasetsCallable = + callableFactory.createUnaryCallable( + listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext); + this.listDatasetsPagedCallable = + callableFactory.createPagedCallable( + listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext); + this.updateDatasetCallable = + callableFactory.createUnaryCallable( + updateDatasetTransportSettings, settings.updateDatasetSettings(), clientContext); + this.deleteDatasetCallable = + callableFactory.createUnaryCallable( + deleteDatasetTransportSettings, settings.deleteDatasetSettings(), clientContext); + this.deleteDatasetOperationCallable = + callableFactory.createOperationCallable( + deleteDatasetTransportSettings, + settings.deleteDatasetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importDataCallable = + callableFactory.createUnaryCallable( + importDataTransportSettings, settings.importDataSettings(), clientContext); + this.importDataOperationCallable = + callableFactory.createOperationCallable( + importDataTransportSettings, + settings.importDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.exportDataCallable = + callableFactory.createUnaryCallable( + exportDataTransportSettings, settings.exportDataSettings(), clientContext); + this.exportDataOperationCallable = + callableFactory.createOperationCallable( + exportDataTransportSettings, + settings.exportDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getAnnotationSpecCallable = + callableFactory.createUnaryCallable( + getAnnotationSpecTransportSettings, + settings.getAnnotationSpecSettings(), + clientContext); + this.getTableSpecCallable = + callableFactory.createUnaryCallable( + getTableSpecTransportSettings, settings.getTableSpecSettings(), clientContext); + this.listTableSpecsCallable = + callableFactory.createUnaryCallable( + listTableSpecsTransportSettings, settings.listTableSpecsSettings(), clientContext); + this.listTableSpecsPagedCallable = + callableFactory.createPagedCallable( + listTableSpecsTransportSettings, settings.listTableSpecsSettings(), clientContext); + this.updateTableSpecCallable = + callableFactory.createUnaryCallable( + updateTableSpecTransportSettings, settings.updateTableSpecSettings(), clientContext); + this.getColumnSpecCallable = + callableFactory.createUnaryCallable( + getColumnSpecTransportSettings, settings.getColumnSpecSettings(), clientContext); + this.listColumnSpecsCallable = + callableFactory.createUnaryCallable( + listColumnSpecsTransportSettings, settings.listColumnSpecsSettings(), clientContext); + this.listColumnSpecsPagedCallable = + callableFactory.createPagedCallable( + listColumnSpecsTransportSettings, settings.listColumnSpecsSettings(), clientContext); + this.updateColumnSpecCallable = + callableFactory.createUnaryCallable( + updateColumnSpecTransportSettings, settings.updateColumnSpecSettings(), clientContext); + this.createModelCallable = + callableFactory.createUnaryCallable( + createModelTransportSettings, settings.createModelSettings(), clientContext); + this.createModelOperationCallable = + callableFactory.createOperationCallable( + createModelTransportSettings, + settings.createModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getModelCallable = + callableFactory.createUnaryCallable( + getModelTransportSettings, settings.getModelSettings(), clientContext); + this.listModelsCallable = + callableFactory.createUnaryCallable( + listModelsTransportSettings, settings.listModelsSettings(), clientContext); + this.listModelsPagedCallable = + callableFactory.createPagedCallable( + listModelsTransportSettings, settings.listModelsSettings(), clientContext); + this.deleteModelCallable = + callableFactory.createUnaryCallable( + deleteModelTransportSettings, settings.deleteModelSettings(), clientContext); + this.deleteModelOperationCallable = + callableFactory.createOperationCallable( + deleteModelTransportSettings, + settings.deleteModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deployModelCallable = + callableFactory.createUnaryCallable( + deployModelTransportSettings, settings.deployModelSettings(), clientContext); + this.deployModelOperationCallable = + callableFactory.createOperationCallable( + deployModelTransportSettings, + settings.deployModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.undeployModelCallable = + callableFactory.createUnaryCallable( + undeployModelTransportSettings, settings.undeployModelSettings(), clientContext); + this.undeployModelOperationCallable = + callableFactory.createOperationCallable( + undeployModelTransportSettings, + settings.undeployModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.exportModelCallable = + callableFactory.createUnaryCallable( + exportModelTransportSettings, settings.exportModelSettings(), clientContext); + this.exportModelOperationCallable = + callableFactory.createOperationCallable( + exportModelTransportSettings, + settings.exportModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.exportEvaluatedExamplesCallable = + callableFactory.createUnaryCallable( + exportEvaluatedExamplesTransportSettings, + settings.exportEvaluatedExamplesSettings(), + clientContext); + this.exportEvaluatedExamplesOperationCallable = + callableFactory.createOperationCallable( + exportEvaluatedExamplesTransportSettings, + settings.exportEvaluatedExamplesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getModelEvaluationCallable = + callableFactory.createUnaryCallable( + getModelEvaluationTransportSettings, + settings.getModelEvaluationSettings(), + clientContext); + this.listModelEvaluationsCallable = + callableFactory.createUnaryCallable( + listModelEvaluationsTransportSettings, + settings.listModelEvaluationsSettings(), + clientContext); + this.listModelEvaluationsPagedCallable = + callableFactory.createPagedCallable( + listModelEvaluationsTransportSettings, + settings.listModelEvaluationsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createDatasetMethodDescriptor); + methodDescriptors.add(getDatasetMethodDescriptor); + methodDescriptors.add(listDatasetsMethodDescriptor); + methodDescriptors.add(updateDatasetMethodDescriptor); + methodDescriptors.add(deleteDatasetMethodDescriptor); + methodDescriptors.add(importDataMethodDescriptor); + methodDescriptors.add(exportDataMethodDescriptor); + methodDescriptors.add(getAnnotationSpecMethodDescriptor); + methodDescriptors.add(getTableSpecMethodDescriptor); + methodDescriptors.add(listTableSpecsMethodDescriptor); + methodDescriptors.add(updateTableSpecMethodDescriptor); + methodDescriptors.add(getColumnSpecMethodDescriptor); + methodDescriptors.add(listColumnSpecsMethodDescriptor); + methodDescriptors.add(updateColumnSpecMethodDescriptor); + methodDescriptors.add(createModelMethodDescriptor); + methodDescriptors.add(getModelMethodDescriptor); + methodDescriptors.add(listModelsMethodDescriptor); + methodDescriptors.add(deleteModelMethodDescriptor); + methodDescriptors.add(deployModelMethodDescriptor); + methodDescriptors.add(undeployModelMethodDescriptor); + methodDescriptors.add(exportModelMethodDescriptor); + methodDescriptors.add(exportEvaluatedExamplesMethodDescriptor); + methodDescriptors.add(getModelEvaluationMethodDescriptor); + methodDescriptors.add(listModelEvaluationsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createDatasetCallable() { + return createDatasetCallable; + } + + @Override + public UnaryCallable getDatasetCallable() { + return getDatasetCallable; + } + + @Override + public UnaryCallable listDatasetsCallable() { + return listDatasetsCallable; + } + + @Override + public UnaryCallable listDatasetsPagedCallable() { + return listDatasetsPagedCallable; + } + + @Override + public UnaryCallable updateDatasetCallable() { + return updateDatasetCallable; + } + + @Override + public UnaryCallable deleteDatasetCallable() { + return deleteDatasetCallable; + } + + @Override + public OperationCallable + deleteDatasetOperationCallable() { + return deleteDatasetOperationCallable; + } + + @Override + public UnaryCallable importDataCallable() { + return importDataCallable; + } + + @Override + public OperationCallable + importDataOperationCallable() { + return importDataOperationCallable; + } + + @Override + public UnaryCallable exportDataCallable() { + return exportDataCallable; + } + + @Override + public OperationCallable + exportDataOperationCallable() { + return exportDataOperationCallable; + } + + @Override + public UnaryCallable getAnnotationSpecCallable() { + return getAnnotationSpecCallable; + } + + @Override + public UnaryCallable getTableSpecCallable() { + return getTableSpecCallable; + } + + @Override + public UnaryCallable listTableSpecsCallable() { + return listTableSpecsCallable; + } + + @Override + public UnaryCallable + listTableSpecsPagedCallable() { + return listTableSpecsPagedCallable; + } + + @Override + public UnaryCallable updateTableSpecCallable() { + return updateTableSpecCallable; + } + + @Override + public UnaryCallable getColumnSpecCallable() { + return getColumnSpecCallable; + } + + @Override + public UnaryCallable listColumnSpecsCallable() { + return listColumnSpecsCallable; + } + + @Override + public UnaryCallable + listColumnSpecsPagedCallable() { + return listColumnSpecsPagedCallable; + } + + @Override + public UnaryCallable updateColumnSpecCallable() { + return updateColumnSpecCallable; + } + + @Override + public UnaryCallable createModelCallable() { + return createModelCallable; + } + + @Override + public OperationCallable + createModelOperationCallable() { + return createModelOperationCallable; + } + + @Override + public UnaryCallable getModelCallable() { + return getModelCallable; + } + + @Override + public UnaryCallable listModelsCallable() { + return listModelsCallable; + } + + @Override + public UnaryCallable listModelsPagedCallable() { + return listModelsPagedCallable; + } + + @Override + public UnaryCallable deleteModelCallable() { + return deleteModelCallable; + } + + @Override + public OperationCallable + deleteModelOperationCallable() { + return deleteModelOperationCallable; + } + + @Override + public UnaryCallable deployModelCallable() { + return deployModelCallable; + } + + @Override + public OperationCallable + deployModelOperationCallable() { + return deployModelOperationCallable; + } + + @Override + public UnaryCallable undeployModelCallable() { + return undeployModelCallable; + } + + @Override + public OperationCallable + undeployModelOperationCallable() { + return undeployModelOperationCallable; + } + + @Override + public UnaryCallable exportModelCallable() { + return exportModelCallable; + } + + @Override + public OperationCallable + exportModelOperationCallable() { + return exportModelOperationCallable; + } + + @Override + public UnaryCallable + exportEvaluatedExamplesCallable() { + return exportEvaluatedExamplesCallable; + } + + @Override + public OperationCallable + exportEvaluatedExamplesOperationCallable() { + return exportEvaluatedExamplesOperationCallable; + } + + @Override + public UnaryCallable getModelEvaluationCallable() { + return getModelEvaluationCallable; + } + + @Override + public UnaryCallable + listModelEvaluationsCallable() { + return listModelEvaluationsCallable; + } + + @Override + public UnaryCallable + listModelEvaluationsPagedCallable() { + return listModelEvaluationsPagedCallable; + } + + @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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonPredictionServiceCallableFactory.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonPredictionServiceCallableFactory.java new file mode 100644 index 000000000..c4f126caa --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/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.automl.v1beta1.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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonPredictionServiceStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonPredictionServiceStub.java new file mode 100644 index 000000000..ac06156c3 --- /dev/null +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/HttpJsonPredictionServiceStub.java @@ -0,0 +1,280 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1beta1.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.automl.v1beta1.BatchPredictRequest; +import com.google.cloud.automl.v1beta1.BatchPredictResult; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.cloud.automl.v1beta1.PredictRequest; +import com.google.cloud.automl.v1beta1.PredictResponse; +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 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() + .add(BatchPredictResult.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + predictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.PredictionService/Predict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}:predict", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PredictResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchPredictMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.automl.v1beta1.PredictionService/BatchPredict") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/models/*}:batchPredict", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchPredictRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable predictCallable; + private final UnaryCallable batchPredictCallable; + private final OperationCallable + batchPredictOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + 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; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings predictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(predictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchPredictTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchPredictMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.predictCallable = + callableFactory.createUnaryCallable( + predictTransportSettings, settings.predictSettings(), clientContext); + this.batchPredictCallable = + callableFactory.createUnaryCallable( + batchPredictTransportSettings, settings.batchPredictSettings(), clientContext); + this.batchPredictOperationCallable = + callableFactory.createOperationCallable( + batchPredictTransportSettings, + settings.batchPredictOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(predictMethodDescriptor); + methodDescriptors.add(batchPredictMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable predictCallable() { + return predictCallable; + } + + @Override + public UnaryCallable batchPredictCallable() { + return batchPredictCallable; + } + + @Override + public OperationCallable + batchPredictOperationCallable() { + return batchPredictOperationCallable; + } + + @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/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStub.java index 9bdeee478..319d0580c 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStub.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStub.java @@ -40,7 +40,11 @@ public abstract class PredictionServiceStub 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 predictCallable() { diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStubSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStubSettings.java index e8ef3bd90..276533d0a 100644 --- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStubSettings.java +++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1beta1/stub/PredictionServiceStubSettings.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; @@ -119,6 +122,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())); @@ -151,18 +159,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)) @@ -170,11 +185,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); @@ -268,6 +302,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/google-cloud-automl/src/test/java/com/google/cloud/automl/v1/AutoMlClientHttpJsonTest.java b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1/AutoMlClientHttpJsonTest.java new file mode 100644 index 000000000..094e666b8 --- /dev/null +++ b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1/AutoMlClientHttpJsonTest.java @@ -0,0 +1,1805 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1; + +import static com.google.cloud.automl.v1.AutoMlClient.ListDatasetsPagedResponse; +import static com.google.cloud.automl.v1.AutoMlClient.ListModelEvaluationsPagedResponse; +import static com.google.cloud.automl.v1.AutoMlClient.ListModelsPagedResponse; + +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.automl.v1.stub.HttpJsonAutoMlStub; +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.Timestamp; +import java.io.IOException; +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 AutoMlClientHttpJsonTest { + private static MockHttpService mockService; + private static AutoMlClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAutoMlStub.getMethodDescriptors(), AutoMlSettings.getDefaultEndpoint()); + AutoMlSettings settings = + AutoMlSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AutoMlSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AutoMlClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createDatasetTest() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Dataset dataset = Dataset.newBuilder().build(); + + Dataset actualResponse = client.createDatasetAsync(parent, dataset).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 createDatasetExceptionTest() 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]"); + Dataset dataset = Dataset.newBuilder().build(); + client.createDatasetAsync(parent, dataset).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createDatasetTest2() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Dataset dataset = Dataset.newBuilder().build(); + + Dataset actualResponse = client.createDatasetAsync(parent, dataset).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 createDatasetExceptionTest2() 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"; + Dataset dataset = Dataset.newBuilder().build(); + client.createDatasetAsync(parent, dataset).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getDatasetTest() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + + Dataset actualResponse = client.getDataset(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 getDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + client.getDataset(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDatasetTest2() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + + Dataset actualResponse = client.getDataset(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 getDatasetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + client.getDataset(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatasetsTest() throws Exception { + Dataset responsesElement = Dataset.newBuilder().build(); + ListDatasetsResponse expectedResponse = + ListDatasetsResponse.newBuilder() + .setNextPageToken("") + .addAllDatasets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListDatasetsPagedResponse pagedListResponse = client.listDatasets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDatasetsList().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 listDatasetsExceptionTest() 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.listDatasets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatasetsTest2() throws Exception { + Dataset responsesElement = Dataset.newBuilder().build(); + ListDatasetsResponse expectedResponse = + ListDatasetsResponse.newBuilder() + .setNextPageToken("") + .addAllDatasets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListDatasetsPagedResponse pagedListResponse = client.listDatasets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDatasetsList().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 listDatasetsExceptionTest2() 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.listDatasets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDatasetTest() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + Dataset dataset = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Dataset actualResponse = client.updateDataset(dataset, 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 updateDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Dataset dataset = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDataset(dataset, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDatasetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + + client.deleteDatasetAsync(name).get(); + + 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 deleteDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + client.deleteDatasetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDatasetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + + client.deleteDatasetAsync(name).get(); + + 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 deleteDatasetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + client.deleteDatasetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDataTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + InputConfig inputConfig = InputConfig.newBuilder().build(); + + client.importDataAsync(name, inputConfig).get(); + + 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 importDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + InputConfig inputConfig = InputConfig.newBuilder().build(); + client.importDataAsync(name, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDataTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + InputConfig inputConfig = InputConfig.newBuilder().build(); + + client.importDataAsync(name, inputConfig).get(); + + 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 importDataExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + InputConfig inputConfig = InputConfig.newBuilder().build(); + client.importDataAsync(name, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportDataTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + + client.exportDataAsync(name, outputConfig).get(); + + 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 exportDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + client.exportDataAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportDataTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + + client.exportDataAsync(name, outputConfig).get(); + + 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 exportDataExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + client.exportDataAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getAnnotationSpecTest() throws Exception { + AnnotationSpec expectedResponse = + AnnotationSpec.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .setDisplayName("displayName1714148973") + .setExampleCount(1517063674) + .build(); + mockService.addResponse(expectedResponse); + + AnnotationSpecName name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]"); + + AnnotationSpec actualResponse = client.getAnnotationSpec(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 getAnnotationSpecExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AnnotationSpecName name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]"); + client.getAnnotationSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAnnotationSpecTest2() throws Exception { + AnnotationSpec expectedResponse = + AnnotationSpec.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .setDisplayName("displayName1714148973") + .setExampleCount(1517063674) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1312/locations/location-1312/datasets/dataset-1312/annotationSpecs/annotationSpec-1312"; + + AnnotationSpec actualResponse = client.getAnnotationSpec(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 getAnnotationSpecExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1312/locations/location-1312/datasets/dataset-1312/annotationSpecs/annotationSpec-1312"; + client.getAnnotationSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createModelTest() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Model model = Model.newBuilder().build(); + + Model actualResponse = client.createModelAsync(parent, model).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 createModelExceptionTest() 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]"); + Model model = Model.newBuilder().build(); + client.createModelAsync(parent, model).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createModelTest2() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Model model = Model.newBuilder().build(); + + Model actualResponse = client.createModelAsync(parent, model).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 createModelExceptionTest2() 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"; + Model model = Model.newBuilder().build(); + client.createModelAsync(parent, model).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getModelTest() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + Model actualResponse = client.getModel(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 getModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.getModel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getModelTest2() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + Model actualResponse = client.getModel(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 getModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.getModel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelsTest() throws Exception { + Model responsesElement = Model.newBuilder().build(); + ListModelsResponse expectedResponse = + ListModelsResponse.newBuilder() + .setNextPageToken("") + .addAllModel(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListModelsPagedResponse pagedListResponse = client.listModels(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelList().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 listModelsExceptionTest() 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.listModels(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelsTest2() throws Exception { + Model responsesElement = Model.newBuilder().build(); + ListModelsResponse expectedResponse = + ListModelsResponse.newBuilder() + .setNextPageToken("") + .addAllModel(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListModelsPagedResponse pagedListResponse = client.listModels(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelList().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 listModelsExceptionTest2() 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.listModels(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + client.deleteModelAsync(name).get(); + + 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 deleteModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.deleteModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + client.deleteModelAsync(name).get(); + + 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 deleteModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.deleteModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateModelTest() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + Model model = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Model actualResponse = client.updateModel(model, 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 updateModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Model model = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateModel(model, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deployModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + client.deployModelAsync(name).get(); + + 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 deployModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.deployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deployModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + client.deployModelAsync(name).get(); + + 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 deployModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.deployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeployModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + client.undeployModelAsync(name).get(); + + 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 undeployModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.undeployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeployModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + client.undeployModelAsync(name).get(); + + 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 undeployModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.undeployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + + client.exportModelAsync(name, outputConfig).get(); + + 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 exportModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + client.exportModelAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + + client.exportModelAsync(name, outputConfig).get(); + + 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 exportModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + client.exportModelAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getModelEvaluationTest() throws Exception { + ModelEvaluation expectedResponse = + ModelEvaluation.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .setAnnotationSpecId("annotationSpecId1320449605") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setEvaluatedExampleCount(277565350) + .build(); + mockService.addResponse(expectedResponse); + + ModelEvaluationName name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"); + + ModelEvaluation actualResponse = client.getModelEvaluation(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 getModelEvaluationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelEvaluationName name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"); + client.getModelEvaluation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getModelEvaluationTest2() throws Exception { + ModelEvaluation expectedResponse = + ModelEvaluation.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .setAnnotationSpecId("annotationSpecId1320449605") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setEvaluatedExampleCount(277565350) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4542/locations/location-4542/models/model-4542/modelEvaluations/modelEvaluation-4542"; + + ModelEvaluation actualResponse = client.getModelEvaluation(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 getModelEvaluationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4542/locations/location-4542/models/model-4542/modelEvaluations/modelEvaluation-4542"; + client.getModelEvaluation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelEvaluationsTest() throws Exception { + ModelEvaluation responsesElement = ModelEvaluation.newBuilder().build(); + ListModelEvaluationsResponse expectedResponse = + ListModelEvaluationsResponse.newBuilder() + .setNextPageToken("") + .addAllModelEvaluation(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + String filter = "filter-1274492040"; + + ListModelEvaluationsPagedResponse pagedListResponse = + client.listModelEvaluations(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelEvaluationList().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 listModelEvaluationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + String filter = "filter-1274492040"; + client.listModelEvaluations(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelEvaluationsTest2() throws Exception { + ModelEvaluation responsesElement = ModelEvaluation.newBuilder().build(); + ListModelEvaluationsResponse expectedResponse = + ListModelEvaluationsResponse.newBuilder() + .setNextPageToken("") + .addAllModelEvaluation(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5605/locations/location-5605/models/model-5605"; + String filter = "filter-1274492040"; + + ListModelEvaluationsPagedResponse pagedListResponse = + client.listModelEvaluations(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelEvaluationList().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 listModelEvaluationsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5605/locations/location-5605/models/model-5605"; + String filter = "filter-1274492040"; + client.listModelEvaluations(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-automl/src/test/java/com/google/cloud/automl/v1/PredictionServiceClientHttpJsonTest.java b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 000000000..9f3bb87e4 --- /dev/null +++ b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,287 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1; + +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.automl.v1.stub.HttpJsonPredictionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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 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() + .addAllPayload(new ArrayList()) + .setPreprocessedInput(ExamplePayload.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + + PredictResponse actualResponse = client.predict(name, payload, params); + 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 { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + client.predict(name, payload, params); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void predictTest2() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllPayload(new ArrayList()) + .setPreprocessedInput(ExamplePayload.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + + PredictResponse actualResponse = client.predict(name, payload, params); + 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 predictExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + client.predict(name, payload, params); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchPredictTest() throws Exception { + BatchPredictResult expectedResponse = + BatchPredictResult.newBuilder().putAllMetadata(new HashMap()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchPredictTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + + BatchPredictResult actualResponse = + client.batchPredictAsync(name, inputConfig, outputConfig, params).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 batchPredictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + client.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchPredictTest2() throws Exception { + BatchPredictResult expectedResponse = + BatchPredictResult.newBuilder().putAllMetadata(new HashMap()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchPredictTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + + BatchPredictResult actualResponse = + client.batchPredictAsync(name, inputConfig, outputConfig, params).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 batchPredictExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + client.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/AutoMlClientHttpJsonTest.java b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/AutoMlClientHttpJsonTest.java new file mode 100644 index 000000000..6b0c0c2f5 --- /dev/null +++ b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/AutoMlClientHttpJsonTest.java @@ -0,0 +1,2363 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1beta1; + +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListColumnSpecsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListDatasetsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListModelEvaluationsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse; +import static com.google.cloud.automl.v1beta1.AutoMlClient.ListTableSpecsPagedResponse; + +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.automl.v1beta1.stub.HttpJsonAutoMlStub; +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.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 AutoMlClientHttpJsonTest { + private static MockHttpService mockService; + private static AutoMlClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAutoMlStub.getMethodDescriptors(), AutoMlSettings.getDefaultEndpoint()); + AutoMlSettings settings = + AutoMlSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AutoMlSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AutoMlClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createDatasetTest() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Dataset dataset = Dataset.newBuilder().build(); + + Dataset actualResponse = client.createDataset(parent, dataset); + 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 createDatasetExceptionTest() 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]"); + Dataset dataset = Dataset.newBuilder().build(); + client.createDataset(parent, dataset); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDatasetTest2() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Dataset dataset = Dataset.newBuilder().build(); + + Dataset actualResponse = client.createDataset(parent, dataset); + 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 createDatasetExceptionTest2() 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"; + Dataset dataset = Dataset.newBuilder().build(); + client.createDataset(parent, dataset); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDatasetTest() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + + Dataset actualResponse = client.getDataset(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 getDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + client.getDataset(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDatasetTest2() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + + Dataset actualResponse = client.getDataset(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 getDatasetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + client.getDataset(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatasetsTest() throws Exception { + Dataset responsesElement = Dataset.newBuilder().build(); + ListDatasetsResponse expectedResponse = + ListDatasetsResponse.newBuilder() + .setNextPageToken("") + .addAllDatasets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListDatasetsPagedResponse pagedListResponse = client.listDatasets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDatasetsList().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 listDatasetsExceptionTest() 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.listDatasets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatasetsTest2() throws Exception { + Dataset responsesElement = Dataset.newBuilder().build(); + ListDatasetsResponse expectedResponse = + ListDatasetsResponse.newBuilder() + .setNextPageToken("") + .addAllDatasets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListDatasetsPagedResponse pagedListResponse = client.listDatasets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDatasetsList().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 listDatasetsExceptionTest2() 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.listDatasets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDatasetTest() throws Exception { + Dataset expectedResponse = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + Dataset dataset = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + + Dataset actualResponse = client.updateDataset(dataset); + 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 updateDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Dataset dataset = + Dataset.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setExampleCount(1517063674) + .setCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + client.updateDataset(dataset); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDatasetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + + client.deleteDatasetAsync(name).get(); + + 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 deleteDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + client.deleteDatasetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDatasetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + + client.deleteDatasetAsync(name).get(); + + 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 deleteDatasetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + client.deleteDatasetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDataTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + InputConfig inputConfig = InputConfig.newBuilder().build(); + + client.importDataAsync(name, inputConfig).get(); + + 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 importDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + InputConfig inputConfig = InputConfig.newBuilder().build(); + client.importDataAsync(name, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDataTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + InputConfig inputConfig = InputConfig.newBuilder().build(); + + client.importDataAsync(name, inputConfig).get(); + + 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 importDataExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + InputConfig inputConfig = InputConfig.newBuilder().build(); + client.importDataAsync(name, inputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportDataTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + + client.exportDataAsync(name, outputConfig).get(); + + 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 exportDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + client.exportDataAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportDataTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + + client.exportDataAsync(name, outputConfig).get(); + + 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 exportDataExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1333/locations/location-1333/datasets/dataset-1333"; + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + client.exportDataAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getAnnotationSpecTest() throws Exception { + AnnotationSpec expectedResponse = + AnnotationSpec.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .setDisplayName("displayName1714148973") + .setExampleCount(1517063674) + .build(); + mockService.addResponse(expectedResponse); + + AnnotationSpecName name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]"); + + AnnotationSpec actualResponse = client.getAnnotationSpec(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 getAnnotationSpecExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AnnotationSpecName name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]"); + client.getAnnotationSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAnnotationSpecTest2() throws Exception { + AnnotationSpec expectedResponse = + AnnotationSpec.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .setDisplayName("displayName1714148973") + .setExampleCount(1517063674) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1312/locations/location-1312/datasets/dataset-1312/annotationSpecs/annotationSpec-1312"; + + AnnotationSpec actualResponse = client.getAnnotationSpec(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 getAnnotationSpecExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1312/locations/location-1312/datasets/dataset-1312/annotationSpecs/annotationSpec-1312"; + client.getAnnotationSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTableSpecTest() throws Exception { + TableSpec expectedResponse = + TableSpec.newBuilder() + .setName( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]").toString()) + .setTimeColumnSpecId("timeColumnSpecId1156268185") + .setRowCount(1340416618) + .setValidRowCount(-406068761) + .setColumnCount(-122671386) + .addAllInputConfigs(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + TableSpecName name = TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]"); + + TableSpec actualResponse = client.getTableSpec(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 getTableSpecExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TableSpecName name = TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]"); + client.getTableSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTableSpecTest2() throws Exception { + TableSpec expectedResponse = + TableSpec.newBuilder() + .setName( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]").toString()) + .setTimeColumnSpecId("timeColumnSpecId1156268185") + .setRowCount(1340416618) + .setValidRowCount(-406068761) + .setColumnCount(-122671386) + .addAllInputConfigs(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5321/locations/location-5321/datasets/dataset-5321/tableSpecs/tableSpec-5321"; + + TableSpec actualResponse = client.getTableSpec(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 getTableSpecExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5321/locations/location-5321/datasets/dataset-5321/tableSpecs/tableSpec-5321"; + client.getTableSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTableSpecsTest() throws Exception { + TableSpec responsesElement = TableSpec.newBuilder().build(); + ListTableSpecsResponse expectedResponse = + ListTableSpecsResponse.newBuilder() + .setNextPageToken("") + .addAllTableSpecs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + DatasetName parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + + ListTableSpecsPagedResponse pagedListResponse = client.listTableSpecs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTableSpecsList().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 listTableSpecsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatasetName parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + client.listTableSpecs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTableSpecsTest2() throws Exception { + TableSpec responsesElement = TableSpec.newBuilder().build(); + ListTableSpecsResponse expectedResponse = + ListTableSpecsResponse.newBuilder() + .setNextPageToken("") + .addAllTableSpecs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-8892/locations/location-8892/datasets/dataset-8892"; + + ListTableSpecsPagedResponse pagedListResponse = client.listTableSpecs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTableSpecsList().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 listTableSpecsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-8892/locations/location-8892/datasets/dataset-8892"; + client.listTableSpecs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateTableSpecTest() throws Exception { + TableSpec expectedResponse = + TableSpec.newBuilder() + .setName( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]").toString()) + .setTimeColumnSpecId("timeColumnSpecId1156268185") + .setRowCount(1340416618) + .setValidRowCount(-406068761) + .setColumnCount(-122671386) + .addAllInputConfigs(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + TableSpec tableSpec = + TableSpec.newBuilder() + .setName( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]").toString()) + .setTimeColumnSpecId("timeColumnSpecId1156268185") + .setRowCount(1340416618) + .setValidRowCount(-406068761) + .setColumnCount(-122671386) + .addAllInputConfigs(new ArrayList()) + .setEtag("etag3123477") + .build(); + + TableSpec actualResponse = client.updateTableSpec(tableSpec); + 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 updateTableSpecExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TableSpec tableSpec = + TableSpec.newBuilder() + .setName( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]") + .toString()) + .setTimeColumnSpecId("timeColumnSpecId1156268185") + .setRowCount(1340416618) + .setValidRowCount(-406068761) + .setColumnCount(-122671386) + .addAllInputConfigs(new ArrayList()) + .setEtag("etag3123477") + .build(); + client.updateTableSpec(tableSpec); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getColumnSpecTest() throws Exception { + ColumnSpec expectedResponse = + ColumnSpec.newBuilder() + .setName( + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString()) + .setDataType(DataType.newBuilder().build()) + .setDisplayName("displayName1714148973") + .setDataStats(DataStats.newBuilder().build()) + .addAllTopCorrelatedColumns(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + ColumnSpecName name = + ColumnSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]"); + + ColumnSpec actualResponse = client.getColumnSpec(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 getColumnSpecExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ColumnSpecName name = + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]"); + client.getColumnSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getColumnSpecTest2() throws Exception { + ColumnSpec expectedResponse = + ColumnSpec.newBuilder() + .setName( + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString()) + .setDataType(DataType.newBuilder().build()) + .setDisplayName("displayName1714148973") + .setDataStats(DataStats.newBuilder().build()) + .addAllTopCorrelatedColumns(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4873/locations/location-4873/datasets/dataset-4873/tableSpecs/tableSpec-4873/columnSpecs/columnSpec-4873"; + + ColumnSpec actualResponse = client.getColumnSpec(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 getColumnSpecExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4873/locations/location-4873/datasets/dataset-4873/tableSpecs/tableSpec-4873/columnSpecs/columnSpec-4873"; + client.getColumnSpec(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listColumnSpecsTest() throws Exception { + ColumnSpec responsesElement = ColumnSpec.newBuilder().build(); + ListColumnSpecsResponse expectedResponse = + ListColumnSpecsResponse.newBuilder() + .setNextPageToken("") + .addAllColumnSpecs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + TableSpecName parent = TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]"); + + ListColumnSpecsPagedResponse pagedListResponse = client.listColumnSpecs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getColumnSpecsList().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 listColumnSpecsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TableSpecName parent = + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]"); + client.listColumnSpecs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listColumnSpecsTest2() throws Exception { + ColumnSpec responsesElement = ColumnSpec.newBuilder().build(); + ListColumnSpecsResponse expectedResponse = + ListColumnSpecsResponse.newBuilder() + .setNextPageToken("") + .addAllColumnSpecs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-7240/locations/location-7240/datasets/dataset-7240/tableSpecs/tableSpec-7240"; + + ListColumnSpecsPagedResponse pagedListResponse = client.listColumnSpecs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getColumnSpecsList().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 listColumnSpecsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-7240/locations/location-7240/datasets/dataset-7240/tableSpecs/tableSpec-7240"; + client.listColumnSpecs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateColumnSpecTest() throws Exception { + ColumnSpec expectedResponse = + ColumnSpec.newBuilder() + .setName( + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString()) + .setDataType(DataType.newBuilder().build()) + .setDisplayName("displayName1714148973") + .setDataStats(DataStats.newBuilder().build()) + .addAllTopCorrelatedColumns(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + ColumnSpec columnSpec = + ColumnSpec.newBuilder() + .setName( + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString()) + .setDataType(DataType.newBuilder().build()) + .setDisplayName("displayName1714148973") + .setDataStats(DataStats.newBuilder().build()) + .addAllTopCorrelatedColumns(new ArrayList()) + .setEtag("etag3123477") + .build(); + + ColumnSpec actualResponse = client.updateColumnSpec(columnSpec); + 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 updateColumnSpecExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ColumnSpec columnSpec = + ColumnSpec.newBuilder() + .setName( + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString()) + .setDataType(DataType.newBuilder().build()) + .setDisplayName("displayName1714148973") + .setDataStats(DataStats.newBuilder().build()) + .addAllTopCorrelatedColumns(new ArrayList()) + .setEtag("etag3123477") + .build(); + client.updateColumnSpec(columnSpec); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createModelTest() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Model model = Model.newBuilder().build(); + + Model actualResponse = client.createModelAsync(parent, model).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 createModelExceptionTest() 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]"); + Model model = Model.newBuilder().build(); + client.createModelAsync(parent, model).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createModelTest2() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Model model = Model.newBuilder().build(); + + Model actualResponse = client.createModelAsync(parent, model).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 createModelExceptionTest2() 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"; + Model model = Model.newBuilder().build(); + client.createModelAsync(parent, model).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getModelTest() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + Model actualResponse = client.getModel(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 getModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.getModel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getModelTest2() throws Exception { + Model expectedResponse = + Model.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setDisplayName("displayName1714148973") + .setDatasetId("datasetId-345342029") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + Model actualResponse = client.getModel(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 getModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.getModel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelsTest() throws Exception { + Model responsesElement = Model.newBuilder().build(); + ListModelsResponse expectedResponse = + ListModelsResponse.newBuilder() + .setNextPageToken("") + .addAllModel(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListModelsPagedResponse pagedListResponse = client.listModels(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelList().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 listModelsExceptionTest() 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.listModels(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelsTest2() throws Exception { + Model responsesElement = Model.newBuilder().build(); + ListModelsResponse expectedResponse = + ListModelsResponse.newBuilder() + .setNextPageToken("") + .addAllModel(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListModelsPagedResponse pagedListResponse = client.listModels(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelList().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 listModelsExceptionTest2() 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.listModels(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + client.deleteModelAsync(name).get(); + + 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 deleteModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.deleteModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + client.deleteModelAsync(name).get(); + + 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 deleteModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.deleteModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deployModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + client.deployModelAsync(name).get(); + + 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 deployModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.deployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deployModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + client.deployModelAsync(name).get(); + + 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 deployModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.deployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeployModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + client.undeployModelAsync(name).get(); + + 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 undeployModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.undeployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeployModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeployModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + + client.undeployModelAsync(name).get(); + + 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 undeployModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + client.undeployModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + + client.exportModelAsync(name, outputConfig).get(); + + 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 exportModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + client.exportModelAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportModelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + + client.exportModelAsync(name, outputConfig).get(); + + 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 exportModelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + client.exportModelAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportEvaluatedExamplesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportEvaluatedExamplesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExportEvaluatedExamplesOutputConfig outputConfig = + ExportEvaluatedExamplesOutputConfig.newBuilder().build(); + + client.exportEvaluatedExamplesAsync(name, outputConfig).get(); + + 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 exportEvaluatedExamplesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExportEvaluatedExamplesOutputConfig outputConfig = + ExportEvaluatedExamplesOutputConfig.newBuilder().build(); + client.exportEvaluatedExamplesAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportEvaluatedExamplesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportEvaluatedExamplesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ExportEvaluatedExamplesOutputConfig outputConfig = + ExportEvaluatedExamplesOutputConfig.newBuilder().build(); + + client.exportEvaluatedExamplesAsync(name, outputConfig).get(); + + 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 exportEvaluatedExamplesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ExportEvaluatedExamplesOutputConfig outputConfig = + ExportEvaluatedExamplesOutputConfig.newBuilder().build(); + client.exportEvaluatedExamplesAsync(name, outputConfig).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getModelEvaluationTest() throws Exception { + ModelEvaluation expectedResponse = + ModelEvaluation.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .setAnnotationSpecId("annotationSpecId1320449605") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setEvaluatedExampleCount(277565350) + .build(); + mockService.addResponse(expectedResponse); + + ModelEvaluationName name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"); + + ModelEvaluation actualResponse = client.getModelEvaluation(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 getModelEvaluationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelEvaluationName name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"); + client.getModelEvaluation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getModelEvaluationTest2() throws Exception { + ModelEvaluation expectedResponse = + ModelEvaluation.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .setAnnotationSpecId("annotationSpecId1320449605") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setEvaluatedExampleCount(277565350) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4542/locations/location-4542/models/model-4542/modelEvaluations/modelEvaluation-4542"; + + ModelEvaluation actualResponse = client.getModelEvaluation(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 getModelEvaluationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4542/locations/location-4542/models/model-4542/modelEvaluations/modelEvaluation-4542"; + client.getModelEvaluation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelEvaluationsTest() throws Exception { + ModelEvaluation responsesElement = ModelEvaluation.newBuilder().build(); + ListModelEvaluationsResponse expectedResponse = + ListModelEvaluationsResponse.newBuilder() + .setNextPageToken("") + .addAllModelEvaluation(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + + ListModelEvaluationsPagedResponse pagedListResponse = client.listModelEvaluations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelEvaluationList().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 listModelEvaluationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + client.listModelEvaluations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listModelEvaluationsTest2() throws Exception { + ModelEvaluation responsesElement = ModelEvaluation.newBuilder().build(); + ListModelEvaluationsResponse expectedResponse = + ListModelEvaluationsResponse.newBuilder() + .setNextPageToken("") + .addAllModelEvaluation(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5605/locations/location-5605/models/model-5605"; + + ListModelEvaluationsPagedResponse pagedListResponse = client.listModelEvaluations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getModelEvaluationList().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 listModelEvaluationsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5605/locations/location-5605/models/model-5605"; + client.listModelEvaluations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/PredictionServiceClientHttpJsonTest.java b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/PredictionServiceClientHttpJsonTest.java new file mode 100644 index 000000000..fc9021824 --- /dev/null +++ b/google-cloud-automl/src/test/java/com/google/cloud/automl/v1beta1/PredictionServiceClientHttpJsonTest.java @@ -0,0 +1,287 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1beta1; + +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.automl.v1beta1.stub.HttpJsonPredictionServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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 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() + .addAllPayload(new ArrayList()) + .setPreprocessedInput(ExamplePayload.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + + PredictResponse actualResponse = client.predict(name, payload, params); + 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 { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + client.predict(name, payload, params); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void predictTest2() throws Exception { + PredictResponse expectedResponse = + PredictResponse.newBuilder() + .addAllPayload(new ArrayList()) + .setPreprocessedInput(ExamplePayload.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + + PredictResponse actualResponse = client.predict(name, payload, params); + 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 predictExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + client.predict(name, payload, params); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchPredictTest() throws Exception { + BatchPredictResult expectedResponse = + BatchPredictResult.newBuilder().putAllMetadata(new HashMap()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchPredictTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + + BatchPredictResult actualResponse = + client.batchPredictAsync(name, inputConfig, outputConfig, params).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 batchPredictExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + client.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchPredictTest2() throws Exception { + BatchPredictResult expectedResponse = + BatchPredictResult.newBuilder().putAllMetadata(new HashMap()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchPredictTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + + BatchPredictResult actualResponse = + client.batchPredictAsync(name, inputConfig, outputConfig, params).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 batchPredictExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7594/locations/location-7594/models/model-7594"; + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + client.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..5e19cbd65 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.AutoMlSettings; +import com.google.cloud.automl.v1.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. + AutoMlSettings autoMlSettings = + AutoMlSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); + } +} +// [END automl_v1_generated_automlclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..243835149 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_create_setcredentialsprovider1_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.AutoMlSettings; + +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. + AutoMlSettings autoMlSettings = + AutoMlSettings.newBuilder() + .setTransportChannelProvider( + AutoMlSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); + } +} +// [END automl_v1_generated_automlclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..ddc0f7469 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1.samples; + +// [START automl_v1_generated_automlclient_create_setendpoint_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.AutoMlSettings; +import com.google.cloud.automl.v1.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. + AutoMlSettings autoMlSettings = AutoMlSettings.newBuilder().setEndpoint(myEndpoint).build(); + AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); + } +} +// [END automl_v1_generated_automlclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDataset.java new file mode 100644 index 000000000..be3e2c441 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createdataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.CreateDatasetRequest; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateDataset { + + public static void main(String[] args) throws Exception { + asyncCreateDataset(); + } + + public static void asyncCreateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateDatasetRequest request = + CreateDatasetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDataset(Dataset.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.createDatasetCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_createdataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDatasetLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDatasetLRO.java new file mode 100644 index 000000000..8e5f22ab7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/AsyncCreateDatasetLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createdataset_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.CreateDatasetRequest; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.OperationMetadata; + +public class AsyncCreateDatasetLRO { + + public static void main(String[] args) throws Exception { + asyncCreateDatasetLRO(); + } + + public static void asyncCreateDatasetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateDatasetRequest request = + CreateDatasetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDataset(Dataset.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.createDatasetOperationCallable().futureCall(request); + // Do something. + Dataset response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_createdataset_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDataset.java new file mode 100644 index 000000000..612f20a70 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createdataset_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.CreateDatasetRequest; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.LocationName; + +public class SyncCreateDataset { + + public static void main(String[] args) throws Exception { + syncCreateDataset(); + } + + public static void syncCreateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateDatasetRequest request = + CreateDatasetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDataset(Dataset.newBuilder().build()) + .build(); + Dataset response = autoMlClient.createDatasetAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_createdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.java new file mode 100644 index 000000000..87ed7b00a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createdataset_locationnamedataset_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.LocationName; + +public class SyncCreateDatasetLocationnameDataset { + + public static void main(String[] args) throws Exception { + syncCreateDatasetLocationnameDataset(); + } + + public static void syncCreateDatasetLocationnameDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Dataset dataset = Dataset.newBuilder().build(); + Dataset response = autoMlClient.createDatasetAsync(parent, dataset).get(); + } + } +} +// [END automl_v1_generated_automlclient_createdataset_locationnamedataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetStringDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetStringDataset.java new file mode 100644 index 000000000..01e56f05d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createdataset/SyncCreateDatasetStringDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createdataset_stringdataset_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.LocationName; + +public class SyncCreateDatasetStringDataset { + + public static void main(String[] args) throws Exception { + syncCreateDatasetStringDataset(); + } + + public static void syncCreateDatasetStringDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Dataset dataset = Dataset.newBuilder().build(); + Dataset response = autoMlClient.createDatasetAsync(parent, dataset).get(); + } + } +} +// [END automl_v1_generated_automlclient_createdataset_stringdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModel.java new file mode 100644 index 000000000..6680d1a40 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.CreateModelRequest; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; +import com.google.longrunning.Operation; + +public class AsyncCreateModel { + + public static void main(String[] args) throws Exception { + asyncCreateModel(); + } + + public static void asyncCreateModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateModelRequest request = + CreateModelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel(Model.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.createModelCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_createmodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModelLRO.java new file mode 100644 index 000000000..d308e2ed0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/AsyncCreateModelLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.CreateModelRequest; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.OperationMetadata; + +public class AsyncCreateModelLRO { + + public static void main(String[] args) throws Exception { + asyncCreateModelLRO(); + } + + public static void asyncCreateModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateModelRequest request = + CreateModelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel(Model.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.createModelOperationCallable().futureCall(request); + // Do something. + Model response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_createmodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModel.java new file mode 100644 index 000000000..f82512ad3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createmodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.CreateModelRequest; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; + +public class SyncCreateModel { + + public static void main(String[] args) throws Exception { + syncCreateModel(); + } + + public static void syncCreateModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateModelRequest request = + CreateModelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel(Model.newBuilder().build()) + .build(); + Model response = autoMlClient.createModelAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_createmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelLocationnameModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelLocationnameModel.java new file mode 100644 index 000000000..8c59ec071 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelLocationnameModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createmodel_locationnamemodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; + +public class SyncCreateModelLocationnameModel { + + public static void main(String[] args) throws Exception { + syncCreateModelLocationnameModel(); + } + + public static void syncCreateModelLocationnameModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Model model = Model.newBuilder().build(); + Model response = autoMlClient.createModelAsync(parent, model).get(); + } + } +} +// [END automl_v1_generated_automlclient_createmodel_locationnamemodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelStringModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelStringModel.java new file mode 100644 index 000000000..eed62ef93 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/createmodel/SyncCreateModelStringModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_createmodel_stringmodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; + +public class SyncCreateModelStringModel { + + public static void main(String[] args) throws Exception { + syncCreateModelStringModel(); + } + + public static void syncCreateModelStringModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Model model = Model.newBuilder().build(); + Model response = autoMlClient.createModelAsync(parent, model).get(); + } + } +} +// [END automl_v1_generated_automlclient_createmodel_stringmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDataset.java new file mode 100644 index 000000000..771347ea2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletedataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.DeleteDatasetRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteDataset { + + public static void main(String[] args) throws Exception { + asyncDeleteDataset(); + } + + public static void asyncDeleteDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteDatasetRequest request = + DeleteDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + ApiFuture future = autoMlClient.deleteDatasetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_deletedataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDatasetLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDatasetLRO.java new file mode 100644 index 000000000..4d16f1d43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/AsyncDeleteDatasetLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletedataset_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.DeleteDatasetRequest; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteDatasetLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteDatasetLRO(); + } + + public static void asyncDeleteDatasetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteDatasetRequest request = + DeleteDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + OperationFuture future = + autoMlClient.deleteDatasetOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_deletedataset_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDataset.java new file mode 100644 index 000000000..461d3181a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletedataset_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.DeleteDatasetRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteDataset { + + public static void main(String[] args) throws Exception { + syncDeleteDataset(); + } + + public static void syncDeleteDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteDatasetRequest request = + DeleteDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + autoMlClient.deleteDatasetAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_deletedataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.java new file mode 100644 index 000000000..ef3622cca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletedataset_datasetname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.protobuf.Empty; + +public class SyncDeleteDatasetDatasetname { + + public static void main(String[] args) throws Exception { + syncDeleteDatasetDatasetname(); + } + + public static void syncDeleteDatasetDatasetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + autoMlClient.deleteDatasetAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_deletedataset_datasetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetString.java new file mode 100644 index 000000000..4a5134aac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletedataset/SyncDeleteDatasetString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletedataset_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.protobuf.Empty; + +public class SyncDeleteDatasetString { + + public static void main(String[] args) throws Exception { + syncDeleteDatasetString(); + } + + public static void syncDeleteDatasetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + autoMlClient.deleteDatasetAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_deletedataset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModel.java new file mode 100644 index 000000000..f60d15cec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletemodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DeleteModelRequest; +import com.google.cloud.automl.v1.ModelName; +import com.google.longrunning.Operation; + +public class AsyncDeleteModel { + + public static void main(String[] args) throws Exception { + asyncDeleteModel(); + } + + public static void asyncDeleteModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteModelRequest request = + DeleteModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.deleteModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_deletemodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModelLRO.java new file mode 100644 index 000000000..d4a174edb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/AsyncDeleteModelLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletemodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DeleteModelRequest; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteModelLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteModelLRO(); + } + + public static void asyncDeleteModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteModelRequest request = + DeleteModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + OperationFuture future = + autoMlClient.deleteModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_deletemodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModel.java new file mode 100644 index 000000000..b580f2765 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletemodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DeleteModelRequest; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeleteModel { + + public static void main(String[] args) throws Exception { + syncDeleteModel(); + } + + public static void syncDeleteModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteModelRequest request = + DeleteModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + autoMlClient.deleteModelAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_deletemodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelModelname.java new file mode 100644 index 000000000..1a2e0e2fc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelModelname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletemodel_modelname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeleteModelModelname { + + public static void main(String[] args) throws Exception { + syncDeleteModelModelname(); + } + + public static void syncDeleteModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + autoMlClient.deleteModelAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_deletemodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelString.java new file mode 100644 index 000000000..a70731a89 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deletemodel/SyncDeleteModelString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deletemodel_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeleteModelString { + + public static void main(String[] args) throws Exception { + syncDeleteModelString(); + } + + public static void syncDeleteModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + autoMlClient.deleteModelAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_deletemodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModel.java new file mode 100644 index 000000000..fc7678a6c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deploymodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DeployModelRequest; +import com.google.cloud.automl.v1.ModelName; +import com.google.longrunning.Operation; + +public class AsyncDeployModel { + + public static void main(String[] args) throws Exception { + asyncDeployModel(); + } + + public static void asyncDeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeployModelRequest request = + DeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.deployModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_deploymodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModelLRO.java new file mode 100644 index 000000000..af8923250 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/AsyncDeployModelLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deploymodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DeployModelRequest; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeployModelLRO { + + public static void main(String[] args) throws Exception { + asyncDeployModelLRO(); + } + + public static void asyncDeployModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeployModelRequest request = + DeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + OperationFuture future = + autoMlClient.deployModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_deploymodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModel.java new file mode 100644 index 000000000..4378836c8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deploymodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DeployModelRequest; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeployModel { + + public static void main(String[] args) throws Exception { + syncDeployModel(); + } + + public static void syncDeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeployModelRequest request = + DeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + autoMlClient.deployModelAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_deploymodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelModelname.java new file mode 100644 index 000000000..9a6f6cdaa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelModelname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deploymodel_modelname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeployModelModelname { + + public static void main(String[] args) throws Exception { + syncDeployModelModelname(); + } + + public static void syncDeployModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + autoMlClient.deployModelAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_deploymodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelString.java new file mode 100644 index 000000000..2425e9773 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/deploymodel/SyncDeployModelString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_deploymodel_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeployModelString { + + public static void main(String[] args) throws Exception { + syncDeployModelString(); + } + + public static void syncDeployModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + autoMlClient.deployModelAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_deploymodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportData.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportData.java new file mode 100644 index 000000000..fe9981e52 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportData.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportdata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.ExportDataRequest; +import com.google.cloud.automl.v1.OutputConfig; +import com.google.longrunning.Operation; + +public class AsyncExportData { + + public static void main(String[] args) throws Exception { + asyncExportData(); + } + + public static void asyncExportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportDataRequest request = + ExportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.exportDataCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_exportdata_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportDataLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportDataLRO.java new file mode 100644 index 000000000..bc3ce3e0b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/AsyncExportDataLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportdata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.ExportDataRequest; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.cloud.automl.v1.OutputConfig; +import com.google.protobuf.Empty; + +public class AsyncExportDataLRO { + + public static void main(String[] args) throws Exception { + asyncExportDataLRO(); + } + + public static void asyncExportDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportDataRequest request = + ExportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.exportDataOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_exportdata_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportData.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportData.java new file mode 100644 index 000000000..166d469b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportData.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportdata_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.ExportDataRequest; +import com.google.cloud.automl.v1.OutputConfig; +import com.google.protobuf.Empty; + +public class SyncExportData { + + public static void main(String[] args) throws Exception { + syncExportData(); + } + + public static void syncExportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportDataRequest request = + ExportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + autoMlClient.exportDataAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_exportdata_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.java new file mode 100644 index 000000000..5d187ea8e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportdata_datasetnameoutputconfig_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.OutputConfig; +import com.google.protobuf.Empty; + +public class SyncExportDataDatasetnameOutputconfig { + + public static void main(String[] args) throws Exception { + syncExportDataDatasetnameOutputconfig(); + } + + public static void syncExportDataDatasetnameOutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + autoMlClient.exportDataAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1_generated_automlclient_exportdata_datasetnameoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataStringOutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataStringOutputconfig.java new file mode 100644 index 000000000..d60cd8ed3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportdata/SyncExportDataStringOutputconfig.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportdata_stringoutputconfig_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.OutputConfig; +import com.google.protobuf.Empty; + +public class SyncExportDataStringOutputconfig { + + public static void main(String[] args) throws Exception { + syncExportDataStringOutputconfig(); + } + + public static void syncExportDataStringOutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + autoMlClient.exportDataAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1_generated_automlclient_exportdata_stringoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModel.java new file mode 100644 index 000000000..452347a50 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ExportModelRequest; +import com.google.cloud.automl.v1.ModelExportOutputConfig; +import com.google.cloud.automl.v1.ModelName; +import com.google.longrunning.Operation; + +public class AsyncExportModel { + + public static void main(String[] args) throws Exception { + asyncExportModel(); + } + + public static void asyncExportModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportModelRequest request = + ExportModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ModelExportOutputConfig.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.exportModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_exportmodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModelLRO.java new file mode 100644 index 000000000..015968681 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/AsyncExportModelLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ExportModelRequest; +import com.google.cloud.automl.v1.ModelExportOutputConfig; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncExportModelLRO { + + public static void main(String[] args) throws Exception { + asyncExportModelLRO(); + } + + public static void asyncExportModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportModelRequest request = + ExportModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ModelExportOutputConfig.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.exportModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_exportmodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModel.java new file mode 100644 index 000000000..8973144a2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportmodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ExportModelRequest; +import com.google.cloud.automl.v1.ModelExportOutputConfig; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportModel { + + public static void main(String[] args) throws Exception { + syncExportModel(); + } + + public static void syncExportModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportModelRequest request = + ExportModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ModelExportOutputConfig.newBuilder().build()) + .build(); + autoMlClient.exportModelAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_exportmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.java new file mode 100644 index 000000000..7f72127e8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportmodel_modelnamemodelexportoutputconfig_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelExportOutputConfig; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportModelModelnameModelexportoutputconfig { + + public static void main(String[] args) throws Exception { + syncExportModelModelnameModelexportoutputconfig(); + } + + public static void syncExportModelModelnameModelexportoutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + autoMlClient.exportModelAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1_generated_automlclient_exportmodel_modelnamemodelexportoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.java new file mode 100644 index 000000000..b3a81d92c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_exportmodel_stringmodelexportoutputconfig_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelExportOutputConfig; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportModelStringModelexportoutputconfig { + + public static void main(String[] args) throws Exception { + syncExportModelStringModelexportoutputconfig(); + } + + public static void syncExportModelStringModelexportoutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + autoMlClient.exportModelAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1_generated_automlclient_exportmodel_stringmodelexportoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/AsyncGetAnnotationSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/AsyncGetAnnotationSpec.java new file mode 100644 index 000000000..c08074e7e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/AsyncGetAnnotationSpec.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getannotationspec_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AnnotationSpec; +import com.google.cloud.automl.v1.AnnotationSpecName; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.GetAnnotationSpecRequest; + +public class AsyncGetAnnotationSpec { + + public static void main(String[] args) throws Exception { + asyncGetAnnotationSpec(); + } + + public static void asyncGetAnnotationSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetAnnotationSpecRequest request = + GetAnnotationSpecRequest.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .build(); + ApiFuture future = + autoMlClient.getAnnotationSpecCallable().futureCall(request); + // Do something. + AnnotationSpec response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_getannotationspec_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpec.java new file mode 100644 index 000000000..777a1246f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpec.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getannotationspec_sync] +import com.google.cloud.automl.v1.AnnotationSpec; +import com.google.cloud.automl.v1.AnnotationSpecName; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.GetAnnotationSpecRequest; + +public class SyncGetAnnotationSpec { + + public static void main(String[] args) throws Exception { + syncGetAnnotationSpec(); + } + + public static void syncGetAnnotationSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetAnnotationSpecRequest request = + GetAnnotationSpecRequest.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .build(); + AnnotationSpec response = autoMlClient.getAnnotationSpec(request); + } + } +} +// [END automl_v1_generated_automlclient_getannotationspec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.java new file mode 100644 index 000000000..f8108ec21 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getannotationspec_annotationspecname_sync] +import com.google.cloud.automl.v1.AnnotationSpec; +import com.google.cloud.automl.v1.AnnotationSpecName; +import com.google.cloud.automl.v1.AutoMlClient; + +public class SyncGetAnnotationSpecAnnotationspecname { + + public static void main(String[] args) throws Exception { + syncGetAnnotationSpecAnnotationspecname(); + } + + public static void syncGetAnnotationSpecAnnotationspecname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + AnnotationSpecName name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]"); + AnnotationSpec response = autoMlClient.getAnnotationSpec(name); + } + } +} +// [END automl_v1_generated_automlclient_getannotationspec_annotationspecname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecString.java new file mode 100644 index 000000000..b7b55488d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getannotationspec/SyncGetAnnotationSpecString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getannotationspec_string_sync] +import com.google.cloud.automl.v1.AnnotationSpec; +import com.google.cloud.automl.v1.AnnotationSpecName; +import com.google.cloud.automl.v1.AutoMlClient; + +public class SyncGetAnnotationSpecString { + + public static void main(String[] args) throws Exception { + syncGetAnnotationSpecString(); + } + + public static void syncGetAnnotationSpecString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString(); + AnnotationSpec response = autoMlClient.getAnnotationSpec(name); + } + } +} +// [END automl_v1_generated_automlclient_getannotationspec_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/AsyncGetDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/AsyncGetDataset.java new file mode 100644 index 000000000..d38347f2e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/AsyncGetDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getdataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.GetDatasetRequest; + +public class AsyncGetDataset { + + public static void main(String[] args) throws Exception { + asyncGetDataset(); + } + + public static void asyncGetDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetDatasetRequest request = + GetDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + ApiFuture future = autoMlClient.getDatasetCallable().futureCall(request); + // Do something. + Dataset response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_getdataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDataset.java new file mode 100644 index 000000000..778a57313 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getdataset_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.GetDatasetRequest; + +public class SyncGetDataset { + + public static void main(String[] args) throws Exception { + syncGetDataset(); + } + + public static void syncGetDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetDatasetRequest request = + GetDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + Dataset response = autoMlClient.getDataset(request); + } + } +} +// [END automl_v1_generated_automlclient_getdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetDatasetname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetDatasetname.java new file mode 100644 index 000000000..a309bf287 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetDatasetname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getdataset_datasetname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.DatasetName; + +public class SyncGetDatasetDatasetname { + + public static void main(String[] args) throws Exception { + syncGetDatasetDatasetname(); + } + + public static void syncGetDatasetDatasetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + Dataset response = autoMlClient.getDataset(name); + } + } +} +// [END automl_v1_generated_automlclient_getdataset_datasetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetString.java new file mode 100644 index 000000000..6986aa539 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getdataset/SyncGetDatasetString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getdataset_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.DatasetName; + +public class SyncGetDatasetString { + + public static void main(String[] args) throws Exception { + syncGetDatasetString(); + } + + public static void syncGetDatasetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + Dataset response = autoMlClient.getDataset(name); + } + } +} +// [END automl_v1_generated_automlclient_getdataset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/AsyncGetModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/AsyncGetModel.java new file mode 100644 index 000000000..433cd92d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/AsyncGetModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.GetModelRequest; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.ModelName; + +public class AsyncGetModel { + + public static void main(String[] args) throws Exception { + asyncGetModel(); + } + + public static void asyncGetModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelRequest request = + GetModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.getModelCallable().futureCall(request); + // Do something. + Model response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_getmodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModel.java new file mode 100644 index 000000000..b2adf74e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.GetModelRequest; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.ModelName; + +public class SyncGetModel { + + public static void main(String[] args) throws Exception { + syncGetModel(); + } + + public static void syncGetModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelRequest request = + GetModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + Model response = autoMlClient.getModel(request); + } + } +} +// [END automl_v1_generated_automlclient_getmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelModelname.java new file mode 100644 index 000000000..f775e4d19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelModelname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodel_modelname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.ModelName; + +public class SyncGetModelModelname { + + public static void main(String[] args) throws Exception { + syncGetModelModelname(); + } + + public static void syncGetModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + Model response = autoMlClient.getModel(name); + } + } +} +// [END automl_v1_generated_automlclient_getmodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelString.java new file mode 100644 index 000000000..18cda01ec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodel/SyncGetModelString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodel_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.ModelName; + +public class SyncGetModelString { + + public static void main(String[] args) throws Exception { + syncGetModelString(); + } + + public static void syncGetModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + Model response = autoMlClient.getModel(name); + } + } +} +// [END automl_v1_generated_automlclient_getmodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.java new file mode 100644 index 000000000..ab62451ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodelevaluation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.GetModelEvaluationRequest; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelEvaluationName; + +public class AsyncGetModelEvaluation { + + public static void main(String[] args) throws Exception { + asyncGetModelEvaluation(); + } + + public static void asyncGetModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelEvaluationRequest request = + GetModelEvaluationRequest.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .build(); + ApiFuture future = + autoMlClient.getModelEvaluationCallable().futureCall(request); + // Do something. + ModelEvaluation response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_getmodelevaluation_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluation.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluation.java new file mode 100644 index 000000000..21fba34c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluation.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodelevaluation_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.GetModelEvaluationRequest; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelEvaluationName; + +public class SyncGetModelEvaluation { + + public static void main(String[] args) throws Exception { + syncGetModelEvaluation(); + } + + public static void syncGetModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelEvaluationRequest request = + GetModelEvaluationRequest.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .build(); + ModelEvaluation response = autoMlClient.getModelEvaluation(request); + } + } +} +// [END automl_v1_generated_automlclient_getmodelevaluation_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.java new file mode 100644 index 000000000..b44a85cbb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodelevaluation_modelevaluationname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelEvaluationName; + +public class SyncGetModelEvaluationModelevaluationname { + + public static void main(String[] args) throws Exception { + syncGetModelEvaluationModelevaluationname(); + } + + public static void syncGetModelEvaluationModelevaluationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelEvaluationName name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"); + ModelEvaluation response = autoMlClient.getModelEvaluation(name); + } + } +} +// [END automl_v1_generated_automlclient_getmodelevaluation_modelevaluationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.java new file mode 100644 index 000000000..b61133788 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_getmodelevaluation_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelEvaluationName; + +public class SyncGetModelEvaluationString { + + public static void main(String[] args) throws Exception { + syncGetModelEvaluationString(); + } + + public static void syncGetModelEvaluationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString(); + ModelEvaluation response = autoMlClient.getModelEvaluation(name); + } + } +} +// [END automl_v1_generated_automlclient_getmodelevaluation_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportData.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportData.java new file mode 100644 index 000000000..9e8e6d3d5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportData.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_importdata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.ImportDataRequest; +import com.google.cloud.automl.v1.InputConfig; +import com.google.longrunning.Operation; + +public class AsyncImportData { + + public static void main(String[] args) throws Exception { + asyncImportData(); + } + + public static void asyncImportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ImportDataRequest request = + ImportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.importDataCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_importdata_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportDataLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportDataLRO.java new file mode 100644 index 000000000..8cb4355db --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/AsyncImportDataLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_importdata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.ImportDataRequest; +import com.google.cloud.automl.v1.InputConfig; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncImportDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportDataLRO(); + } + + public static void asyncImportDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ImportDataRequest request = + ImportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.importDataOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_importdata_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportData.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportData.java new file mode 100644 index 000000000..66d538203 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportData.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_importdata_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.ImportDataRequest; +import com.google.cloud.automl.v1.InputConfig; +import com.google.protobuf.Empty; + +public class SyncImportData { + + public static void main(String[] args) throws Exception { + syncImportData(); + } + + public static void syncImportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ImportDataRequest request = + ImportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + autoMlClient.importDataAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_importdata_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.java new file mode 100644 index 000000000..eda5760b6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_importdata_datasetnameinputconfig_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.InputConfig; +import com.google.protobuf.Empty; + +public class SyncImportDataDatasetnameInputconfig { + + public static void main(String[] args) throws Exception { + syncImportDataDatasetnameInputconfig(); + } + + public static void syncImportDataDatasetnameInputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + InputConfig inputConfig = InputConfig.newBuilder().build(); + autoMlClient.importDataAsync(name, inputConfig).get(); + } + } +} +// [END automl_v1_generated_automlclient_importdata_datasetnameinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataStringInputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataStringInputconfig.java new file mode 100644 index 000000000..0ec86a3e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/importdata/SyncImportDataStringInputconfig.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_importdata_stringinputconfig_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.DatasetName; +import com.google.cloud.automl.v1.InputConfig; +import com.google.protobuf.Empty; + +public class SyncImportDataStringInputconfig { + + public static void main(String[] args) throws Exception { + syncImportDataStringInputconfig(); + } + + public static void syncImportDataStringInputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + InputConfig inputConfig = InputConfig.newBuilder().build(); + autoMlClient.importDataAsync(name, inputConfig).get(); + } + } +} +// [END automl_v1_generated_automlclient_importdata_stringinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasets.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasets.java new file mode 100644 index 000000000..ef2e92b7d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasets.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listdatasets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.ListDatasetsRequest; +import com.google.cloud.automl.v1.LocationName; + +public class AsyncListDatasets { + + public static void main(String[] args) throws Exception { + asyncListDatasets(); + } + + public static void asyncListDatasets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListDatasetsRequest request = + ListDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = autoMlClient.listDatasetsPagedCallable().futureCall(request); + // Do something. + for (Dataset element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listdatasets_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasetsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasetsPaged.java new file mode 100644 index 000000000..3b8aa359e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/AsyncListDatasetsPaged.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listdatasets_paged_async] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.ListDatasetsRequest; +import com.google.cloud.automl.v1.ListDatasetsResponse; +import com.google.cloud.automl.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListDatasetsPaged { + + public static void main(String[] args) throws Exception { + asyncListDatasetsPaged(); + } + + public static void asyncListDatasetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListDatasetsRequest request = + ListDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListDatasetsResponse response = autoMlClient.listDatasetsCallable().call(request); + for (Dataset element : response.getDatasetsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1_generated_automlclient_listdatasets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasets.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasets.java new file mode 100644 index 000000000..4178ddc88 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasets.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listdatasets_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.ListDatasetsRequest; +import com.google.cloud.automl.v1.LocationName; + +public class SyncListDatasets { + + public static void main(String[] args) throws Exception { + syncListDatasets(); + } + + public static void syncListDatasets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListDatasetsRequest request = + ListDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Dataset element : autoMlClient.listDatasets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listdatasets_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsLocationname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsLocationname.java new file mode 100644 index 000000000..fa70e2676 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsLocationname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listdatasets_locationname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.LocationName; + +public class SyncListDatasetsLocationname { + + public static void main(String[] args) throws Exception { + syncListDatasetsLocationname(); + } + + public static void syncListDatasetsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Dataset element : autoMlClient.listDatasets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listdatasets_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsString.java new file mode 100644 index 000000000..7473f6b4f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listdatasets/SyncListDatasetsString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listdatasets_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.LocationName; + +public class SyncListDatasetsString { + + public static void main(String[] args) throws Exception { + syncListDatasetsString(); + } + + public static void syncListDatasetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Dataset element : autoMlClient.listDatasets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listdatasets_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluations.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluations.java new file mode 100644 index 000000000..8cd815db5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluations.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodelevaluations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelName; + +public class AsyncListModelEvaluations { + + public static void main(String[] args) throws Exception { + asyncListModelEvaluations(); + } + + public static void asyncListModelEvaluations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelEvaluationsRequest request = + ListModelEvaluationsRequest.newBuilder() + .setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + autoMlClient.listModelEvaluationsPagedCallable().futureCall(request); + // Do something. + for (ModelEvaluation element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodelevaluations_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.java new file mode 100644 index 000000000..5820c8e87 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodelevaluations_paged_async] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1.ListModelEvaluationsResponse; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelName; +import com.google.common.base.Strings; + +public class AsyncListModelEvaluationsPaged { + + public static void main(String[] args) throws Exception { + asyncListModelEvaluationsPaged(); + } + + public static void asyncListModelEvaluationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelEvaluationsRequest request = + ListModelEvaluationsRequest.newBuilder() + .setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListModelEvaluationsResponse response = + autoMlClient.listModelEvaluationsCallable().call(request); + for (ModelEvaluation element : response.getModelEvaluationList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1_generated_automlclient_listmodelevaluations_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluations.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluations.java new file mode 100644 index 000000000..5a848d294 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluations.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodelevaluations_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelName; + +public class SyncListModelEvaluations { + + public static void main(String[] args) throws Exception { + syncListModelEvaluations(); + } + + public static void syncListModelEvaluations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelEvaluationsRequest request = + ListModelEvaluationsRequest.newBuilder() + .setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ModelEvaluation element : autoMlClient.listModelEvaluations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodelevaluations_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelnameString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelnameString.java new file mode 100644 index 000000000..c62e16174 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelnameString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodelevaluations_modelnamestring_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelName; + +public class SyncListModelEvaluationsModelnameString { + + public static void main(String[] args) throws Exception { + syncListModelEvaluationsModelnameString(); + } + + public static void syncListModelEvaluationsModelnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + String filter = "filter-1274492040"; + for (ModelEvaluation element : + autoMlClient.listModelEvaluations(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodelevaluations_modelnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsStringString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsStringString.java new file mode 100644 index 000000000..ac6ecb405 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodelevaluations/SyncListModelEvaluationsStringString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodelevaluations_stringstring_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelEvaluation; +import com.google.cloud.automl.v1.ModelName; + +public class SyncListModelEvaluationsStringString { + + public static void main(String[] args) throws Exception { + syncListModelEvaluationsStringString(); + } + + public static void syncListModelEvaluationsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + String filter = "filter-1274492040"; + for (ModelEvaluation element : + autoMlClient.listModelEvaluations(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodelevaluations_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModels.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModels.java new file mode 100644 index 000000000..9965716eb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModels.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodels_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ListModelsRequest; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; + +public class AsyncListModels { + + public static void main(String[] args) throws Exception { + asyncListModels(); + } + + public static void asyncListModels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelsRequest request = + ListModelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = autoMlClient.listModelsPagedCallable().futureCall(request); + // Do something. + for (Model element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodels_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModelsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModelsPaged.java new file mode 100644 index 000000000..23cd8c9b6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/AsyncListModelsPaged.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodels_paged_async] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ListModelsRequest; +import com.google.cloud.automl.v1.ListModelsResponse; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; +import com.google.common.base.Strings; + +public class AsyncListModelsPaged { + + public static void main(String[] args) throws Exception { + asyncListModelsPaged(); + } + + public static void asyncListModelsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelsRequest request = + ListModelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListModelsResponse response = autoMlClient.listModelsCallable().call(request); + for (Model element : response.getModelList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1_generated_automlclient_listmodels_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModels.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModels.java new file mode 100644 index 000000000..ee2c466f2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModels.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodels_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ListModelsRequest; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; + +public class SyncListModels { + + public static void main(String[] args) throws Exception { + syncListModels(); + } + + public static void syncListModels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelsRequest request = + ListModelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Model element : autoMlClient.listModels(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodels_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsLocationname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsLocationname.java new file mode 100644 index 000000000..5047a8d53 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsLocationname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodels_locationname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; + +public class SyncListModelsLocationname { + + public static void main(String[] args) throws Exception { + syncListModelsLocationname(); + } + + public static void syncListModelsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Model element : autoMlClient.listModels(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodels_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsString.java new file mode 100644 index 000000000..45f261071 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/listmodels/SyncListModelsString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_listmodels_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.LocationName; +import com.google.cloud.automl.v1.Model; + +public class SyncListModelsString { + + public static void main(String[] args) throws Exception { + syncListModelsString(); + } + + public static void syncListModelsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Model element : autoMlClient.listModels(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1_generated_automlclient_listmodels_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModel.java new file mode 100644 index 000000000..191612b2c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_undeploymodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.UndeployModelRequest; +import com.google.longrunning.Operation; + +public class AsyncUndeployModel { + + public static void main(String[] args) throws Exception { + asyncUndeployModel(); + } + + public static void asyncUndeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UndeployModelRequest request = + UndeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.undeployModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_undeploymodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModelLRO.java new file mode 100644 index 000000000..6041f7b6d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/AsyncUndeployModelLRO.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_undeploymodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.cloud.automl.v1.UndeployModelRequest; +import com.google.protobuf.Empty; + +public class AsyncUndeployModelLRO { + + public static void main(String[] args) throws Exception { + asyncUndeployModelLRO(); + } + + public static void asyncUndeployModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UndeployModelRequest request = + UndeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + OperationFuture future = + autoMlClient.undeployModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1_generated_automlclient_undeploymodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModel.java new file mode 100644 index 000000000..5d511c826 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_undeploymodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.UndeployModelRequest; +import com.google.protobuf.Empty; + +public class SyncUndeployModel { + + public static void main(String[] args) throws Exception { + syncUndeployModel(); + } + + public static void syncUndeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UndeployModelRequest request = + UndeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + autoMlClient.undeployModelAsync(request).get(); + } + } +} +// [END automl_v1_generated_automlclient_undeploymodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelModelname.java new file mode 100644 index 000000000..a64a03553 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelModelname.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_undeploymodel_modelname_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncUndeployModelModelname { + + public static void main(String[] args) throws Exception { + syncUndeployModelModelname(); + } + + public static void syncUndeployModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + autoMlClient.undeployModelAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_undeploymodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelString.java new file mode 100644 index 000000000..b0b9f64ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/undeploymodel/SyncUndeployModelString.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_undeploymodel_string_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.ModelName; +import com.google.protobuf.Empty; + +public class SyncUndeployModelString { + + public static void main(String[] args) throws Exception { + syncUndeployModelString(); + } + + public static void syncUndeployModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + autoMlClient.undeployModelAsync(name).get(); + } + } +} +// [END automl_v1_generated_automlclient_undeploymodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/AsyncUpdateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/AsyncUpdateDataset.java new file mode 100644 index 000000000..471c70f09 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/AsyncUpdateDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_updatedataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.UpdateDatasetRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDataset { + + public static void main(String[] args) throws Exception { + asyncUpdateDataset(); + } + + public static void asyncUpdateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateDatasetRequest request = + UpdateDatasetRequest.newBuilder() + .setDataset(Dataset.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.updateDatasetCallable().futureCall(request); + // Do something. + Dataset response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_updatedataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDataset.java new file mode 100644 index 000000000..1e81548f6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_updatedataset_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.cloud.automl.v1.UpdateDatasetRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDataset { + + public static void main(String[] args) throws Exception { + syncUpdateDataset(); + } + + public static void syncUpdateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateDatasetRequest request = + UpdateDatasetRequest.newBuilder() + .setDataset(Dataset.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Dataset response = autoMlClient.updateDataset(request); + } + } +} +// [END automl_v1_generated_automlclient_updatedataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDatasetDatasetFieldmask.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDatasetDatasetFieldmask.java new file mode 100644 index 000000000..2c80d2ce4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatedataset/SyncUpdateDatasetDatasetFieldmask.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_updatedataset_datasetfieldmask_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Dataset; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDatasetDatasetFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateDatasetDatasetFieldmask(); + } + + public static void syncUpdateDatasetDatasetFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + Dataset dataset = Dataset.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Dataset response = autoMlClient.updateDataset(dataset, updateMask); + } + } +} +// [END automl_v1_generated_automlclient_updatedataset_datasetfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/AsyncUpdateModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/AsyncUpdateModel.java new file mode 100644 index 000000000..6c87691c7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/AsyncUpdateModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_updatemodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.UpdateModelRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateModel { + + public static void main(String[] args) throws Exception { + asyncUpdateModel(); + } + + public static void asyncUpdateModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateModelRequest request = + UpdateModelRequest.newBuilder() + .setModel(Model.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.updateModelCallable().futureCall(request); + // Do something. + Model response = future.get(); + } + } +} +// [END automl_v1_generated_automlclient_updatemodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModel.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModel.java new file mode 100644 index 000000000..6ac5e82db --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModel.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_updatemodel_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Model; +import com.google.cloud.automl.v1.UpdateModelRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateModel { + + public static void main(String[] args) throws Exception { + syncUpdateModel(); + } + + public static void syncUpdateModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateModelRequest request = + UpdateModelRequest.newBuilder() + .setModel(Model.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Model response = autoMlClient.updateModel(request); + } + } +} +// [END automl_v1_generated_automlclient_updatemodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModelModelFieldmask.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModelModelFieldmask.java new file mode 100644 index 000000000..447a70af7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlclient/updatemodel/SyncUpdateModelModelFieldmask.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.automl.v1.samples; + +// [START automl_v1_generated_automlclient_updatemodel_modelfieldmask_sync] +import com.google.cloud.automl.v1.AutoMlClient; +import com.google.cloud.automl.v1.Model; +import com.google.protobuf.FieldMask; + +public class SyncUpdateModelModelFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateModelModelFieldmask(); + } + + public static void syncUpdateModelModelFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + Model model = Model.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Model response = autoMlClient.updateModel(model, updateMask); + } + } +} +// [END automl_v1_generated_automlclient_updatemodel_modelfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/automlsettings/getdataset/SyncGetDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/automlsettings/getdataset/SyncGetDataset.java new file mode 100644 index 000000000..40ac6f780 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/automlsettings/getdataset/SyncGetDataset.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.automl.v1.samples; + +// [START automl_v1_generated_automlsettings_getdataset_sync] +import com.google.cloud.automl.v1.AutoMlSettings; +import java.time.Duration; + +public class SyncGetDataset { + + public static void main(String[] args) throws Exception { + syncGetDataset(); + } + + public static void syncGetDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AutoMlSettings.Builder autoMlSettingsBuilder = AutoMlSettings.newBuilder(); + autoMlSettingsBuilder + .getDatasetSettings() + .setRetrySettings( + autoMlSettingsBuilder + .getDatasetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AutoMlSettings autoMlSettings = autoMlSettingsBuilder.build(); + } +} +// [END automl_v1_generated_automlsettings_getdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredict.java new file mode 100644 index 000000000..6f290136f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredict.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_batchpredict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.BatchPredictInputConfig; +import com.google.cloud.automl.v1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1.BatchPredictRequest; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictionServiceClient; +import com.google.longrunning.Operation; +import java.util.HashMap; + +public class AsyncBatchPredict { + + public static void main(String[] args) throws Exception { + asyncBatchPredict(); + } + + public static void asyncBatchPredict() 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()) { + BatchPredictRequest request = + BatchPredictRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setInputConfig(BatchPredictInputConfig.newBuilder().build()) + .setOutputConfig(BatchPredictOutputConfig.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.batchPredictCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END automl_v1_generated_predictionserviceclient_batchpredict_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.java new file mode 100644 index 000000000..3e9d6d1ef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_batchpredict_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1.BatchPredictInputConfig; +import com.google.cloud.automl.v1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1.BatchPredictRequest; +import com.google.cloud.automl.v1.BatchPredictResult; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.OperationMetadata; +import com.google.cloud.automl.v1.PredictionServiceClient; +import java.util.HashMap; + +public class AsyncBatchPredictLRO { + + public static void main(String[] args) throws Exception { + asyncBatchPredictLRO(); + } + + public static void asyncBatchPredictLRO() 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()) { + BatchPredictRequest request = + BatchPredictRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setInputConfig(BatchPredictInputConfig.newBuilder().build()) + .setOutputConfig(BatchPredictOutputConfig.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + OperationFuture future = + predictionServiceClient.batchPredictOperationCallable().futureCall(request); + // Do something. + BatchPredictResult response = future.get(); + } + } +} +// [END automl_v1_generated_predictionserviceclient_batchpredict_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredict.java new file mode 100644 index 000000000..ce61d14b8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredict.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_batchpredict_sync] +import com.google.cloud.automl.v1.BatchPredictInputConfig; +import com.google.cloud.automl.v1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1.BatchPredictRequest; +import com.google.cloud.automl.v1.BatchPredictResult; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictionServiceClient; +import java.util.HashMap; + +public class SyncBatchPredict { + + public static void main(String[] args) throws Exception { + syncBatchPredict(); + } + + public static void syncBatchPredict() 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()) { + BatchPredictRequest request = + BatchPredictRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setInputConfig(BatchPredictInputConfig.newBuilder().build()) + .setOutputConfig(BatchPredictOutputConfig.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + BatchPredictResult response = predictionServiceClient.batchPredictAsync(request).get(); + } + } +} +// [END automl_v1_generated_predictionserviceclient_batchpredict_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java new file mode 100644 index 000000000..1aa44d13c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_batchpredict_modelnamebatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] +import com.google.cloud.automl.v1.BatchPredictInputConfig; +import com.google.cloud.automl.v1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1.BatchPredictResult; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public +class SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring { + + public static void main(String[] args) throws Exception { + syncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring(); + } + + public static void + syncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring() + 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()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + BatchPredictResult response = + predictionServiceClient.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + } + } +} +// [END automl_v1_generated_predictionserviceclient_batchpredict_modelnamebatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java new file mode 100644 index 000000000..166deca52 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_batchpredict_stringbatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] +import com.google.cloud.automl.v1.BatchPredictInputConfig; +import com.google.cloud.automl.v1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1.BatchPredictResult; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring { + + public static void main(String[] args) throws Exception { + syncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring(); + } + + public static void + syncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring() + 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()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + BatchPredictResult response = + predictionServiceClient.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + } + } +} +// [END automl_v1_generated_predictionserviceclient_batchpredict_stringbatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..d586636d3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.automl.v1.PredictionServiceClient; +import com.google.cloud.automl.v1.PredictionServiceSettings; +import com.google.cloud.automl.v1.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 automl_v1_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..9a3d8707f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.automl.v1.PredictionServiceClient; +import com.google.cloud.automl.v1.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 automl_v1_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..e7c53e75a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.automl.v1.PredictionServiceClient; +import com.google.cloud.automl.v1.PredictionServiceSettings; +import com.google.cloud.automl.v1.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 automl_v1_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/AsyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 000000000..7a9471c0c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/AsyncPredict.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1.ExamplePayload; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictRequest; +import com.google.cloud.automl.v1.PredictResponse; +import com.google.cloud.automl.v1.PredictionServiceClient; +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() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setPayload(ExamplePayload.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END automl_v1_generated_predictionserviceclient_predict_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 000000000..bff28ea03 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_predict_sync] +import com.google.cloud.automl.v1.ExamplePayload; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictRequest; +import com.google.cloud.automl.v1.PredictResponse; +import com.google.cloud.automl.v1.PredictionServiceClient; +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() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setPayload(ExamplePayload.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END automl_v1_generated_predictionserviceclient_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.java new file mode 100644 index 000000000..1bff33584 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_predict_modelnameexamplepayloadmapstringstring_sync] +import com.google.cloud.automl.v1.ExamplePayload; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictResponse; +import com.google.cloud.automl.v1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncPredictModelnameExamplepayloadMapstringstring { + + public static void main(String[] args) throws Exception { + syncPredictModelnameExamplepayloadMapstringstring(); + } + + public static void syncPredictModelnameExamplepayloadMapstringstring() 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()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + PredictResponse response = predictionServiceClient.predict(name, payload, params); + } + } +} +// [END automl_v1_generated_predictionserviceclient_predict_modelnameexamplepayloadmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.java new file mode 100644 index 000000000..9527930c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.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.automl.v1.samples; + +// [START automl_v1_generated_predictionserviceclient_predict_stringexamplepayloadmapstringstring_sync] +import com.google.cloud.automl.v1.ExamplePayload; +import com.google.cloud.automl.v1.ModelName; +import com.google.cloud.automl.v1.PredictResponse; +import com.google.cloud.automl.v1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncPredictStringExamplepayloadMapstringstring { + + public static void main(String[] args) throws Exception { + syncPredictStringExamplepayloadMapstringstring(); + } + + public static void syncPredictStringExamplepayloadMapstringstring() 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()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + PredictResponse response = predictionServiceClient.predict(name, payload, params); + } + } +} +// [END automl_v1_generated_predictionserviceclient_predict_stringexamplepayloadmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/predictionservicesettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 000000000..a79b85e5a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/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.automl.v1.samples; + +// [START automl_v1_generated_predictionservicesettings_predict_sync] +import com.google.cloud.automl.v1.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 automl_v1_generated_predictionservicesettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/stub/automlstubsettings/getdataset/SyncGetDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1/stub/automlstubsettings/getdataset/SyncGetDataset.java new file mode 100644 index 000000000..64171d868 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/stub/automlstubsettings/getdataset/SyncGetDataset.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.automl.v1.stub.samples; + +// [START automl_v1_generated_automlstubsettings_getdataset_sync] +import com.google.cloud.automl.v1.stub.AutoMlStubSettings; +import java.time.Duration; + +public class SyncGetDataset { + + public static void main(String[] args) throws Exception { + syncGetDataset(); + } + + public static void syncGetDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AutoMlStubSettings.Builder autoMlSettingsBuilder = AutoMlStubSettings.newBuilder(); + autoMlSettingsBuilder + .getDatasetSettings() + .setRetrySettings( + autoMlSettingsBuilder + .getDatasetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AutoMlStubSettings autoMlSettings = autoMlSettingsBuilder.build(); + } +} +// [END automl_v1_generated_automlstubsettings_getdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1/stub/predictionservicestubsettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 000000000..82f26e88e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1/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.automl.v1.stub.samples; + +// [START automl_v1_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.automl.v1.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 automl_v1_generated_predictionservicestubsettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..0090c825c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.AutoMlSettings; +import com.google.cloud.automl.v1beta1.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. + AutoMlSettings autoMlSettings = + AutoMlSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); + } +} +// [END automl_v1beta1_generated_automlclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..c1644da09 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_create_setcredentialsprovider1_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.AutoMlSettings; + +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. + AutoMlSettings autoMlSettings = + AutoMlSettings.newBuilder() + .setTransportChannelProvider( + AutoMlSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); + } +} +// [END automl_v1beta1_generated_automlclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..6009311c7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_create_setendpoint_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.AutoMlSettings; +import com.google.cloud.automl.v1beta1.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. + AutoMlSettings autoMlSettings = AutoMlSettings.newBuilder().setEndpoint(myEndpoint).build(); + AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings); + } +} +// [END automl_v1beta1_generated_automlclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/AsyncCreateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/AsyncCreateDataset.java new file mode 100644 index 000000000..74fee32ba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/AsyncCreateDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createdataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.CreateDatasetRequest; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.LocationName; + +public class AsyncCreateDataset { + + public static void main(String[] args) throws Exception { + asyncCreateDataset(); + } + + public static void asyncCreateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateDatasetRequest request = + CreateDatasetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDataset(Dataset.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.createDatasetCallable().futureCall(request); + // Do something. + Dataset response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_createdataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDataset.java new file mode 100644 index 000000000..e08c2c6d5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createdataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.CreateDatasetRequest; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.LocationName; + +public class SyncCreateDataset { + + public static void main(String[] args) throws Exception { + syncCreateDataset(); + } + + public static void syncCreateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateDatasetRequest request = + CreateDatasetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDataset(Dataset.newBuilder().build()) + .build(); + Dataset response = autoMlClient.createDataset(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_createdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.java new file mode 100644 index 000000000..ad56c31e0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetLocationnameDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createdataset_locationnamedataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.LocationName; + +public class SyncCreateDatasetLocationnameDataset { + + public static void main(String[] args) throws Exception { + syncCreateDatasetLocationnameDataset(); + } + + public static void syncCreateDatasetLocationnameDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Dataset dataset = Dataset.newBuilder().build(); + Dataset response = autoMlClient.createDataset(parent, dataset); + } + } +} +// [END automl_v1beta1_generated_automlclient_createdataset_locationnamedataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetStringDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetStringDataset.java new file mode 100644 index 000000000..3a1f037b0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createdataset/SyncCreateDatasetStringDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createdataset_stringdataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.LocationName; + +public class SyncCreateDatasetStringDataset { + + public static void main(String[] args) throws Exception { + syncCreateDatasetStringDataset(); + } + + public static void syncCreateDatasetStringDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Dataset dataset = Dataset.newBuilder().build(); + Dataset response = autoMlClient.createDataset(parent, dataset); + } + } +} +// [END automl_v1beta1_generated_automlclient_createdataset_stringdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModel.java new file mode 100644 index 000000000..87c28af75 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.CreateModelRequest; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; +import com.google.longrunning.Operation; + +public class AsyncCreateModel { + + public static void main(String[] args) throws Exception { + asyncCreateModel(); + } + + public static void asyncCreateModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateModelRequest request = + CreateModelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel(Model.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.createModelCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_createmodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModelLRO.java new file mode 100644 index 000000000..4d04c449f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/AsyncCreateModelLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.CreateModelRequest; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; +import com.google.cloud.automl.v1beta1.OperationMetadata; + +public class AsyncCreateModelLRO { + + public static void main(String[] args) throws Exception { + asyncCreateModelLRO(); + } + + public static void asyncCreateModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateModelRequest request = + CreateModelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel(Model.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.createModelOperationCallable().futureCall(request); + // Do something. + Model response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_createmodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModel.java new file mode 100644 index 000000000..19607aaf6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createmodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.CreateModelRequest; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; + +public class SyncCreateModel { + + public static void main(String[] args) throws Exception { + syncCreateModel(); + } + + public static void syncCreateModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + CreateModelRequest request = + CreateModelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel(Model.newBuilder().build()) + .build(); + Model response = autoMlClient.createModelAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_createmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelLocationnameModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelLocationnameModel.java new file mode 100644 index 000000000..b3d13eaeb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelLocationnameModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createmodel_locationnamemodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; + +public class SyncCreateModelLocationnameModel { + + public static void main(String[] args) throws Exception { + syncCreateModelLocationnameModel(); + } + + public static void syncCreateModelLocationnameModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Model model = Model.newBuilder().build(); + Model response = autoMlClient.createModelAsync(parent, model).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_createmodel_locationnamemodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelStringModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelStringModel.java new file mode 100644 index 000000000..a165181e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/createmodel/SyncCreateModelStringModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_createmodel_stringmodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; + +public class SyncCreateModelStringModel { + + public static void main(String[] args) throws Exception { + syncCreateModelStringModel(); + } + + public static void syncCreateModelStringModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Model model = Model.newBuilder().build(); + Model response = autoMlClient.createModelAsync(parent, model).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_createmodel_stringmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDataset.java new file mode 100644 index 000000000..b13445dee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletedataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.DeleteDatasetRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteDataset { + + public static void main(String[] args) throws Exception { + asyncDeleteDataset(); + } + + public static void asyncDeleteDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteDatasetRequest request = + DeleteDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + ApiFuture future = autoMlClient.deleteDatasetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletedataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDatasetLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDatasetLRO.java new file mode 100644 index 000000000..96a8857ee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/AsyncDeleteDatasetLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletedataset_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.DeleteDatasetRequest; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteDatasetLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteDatasetLRO(); + } + + public static void asyncDeleteDatasetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteDatasetRequest request = + DeleteDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + OperationFuture future = + autoMlClient.deleteDatasetOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletedataset_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDataset.java new file mode 100644 index 000000000..ad98bb4bd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletedataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.DeleteDatasetRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteDataset { + + public static void main(String[] args) throws Exception { + syncDeleteDataset(); + } + + public static void syncDeleteDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteDatasetRequest request = + DeleteDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + autoMlClient.deleteDatasetAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletedataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.java new file mode 100644 index 000000000..4a0500484 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetDatasetname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletedataset_datasetname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.protobuf.Empty; + +public class SyncDeleteDatasetDatasetname { + + public static void main(String[] args) throws Exception { + syncDeleteDatasetDatasetname(); + } + + public static void syncDeleteDatasetDatasetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + autoMlClient.deleteDatasetAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletedataset_datasetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetString.java new file mode 100644 index 000000000..6ffcc77a4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletedataset/SyncDeleteDatasetString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletedataset_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.protobuf.Empty; + +public class SyncDeleteDatasetString { + + public static void main(String[] args) throws Exception { + syncDeleteDatasetString(); + } + + public static void syncDeleteDatasetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + autoMlClient.deleteDatasetAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletedataset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModel.java new file mode 100644 index 000000000..ab85b51e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletemodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DeleteModelRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.longrunning.Operation; + +public class AsyncDeleteModel { + + public static void main(String[] args) throws Exception { + asyncDeleteModel(); + } + + public static void asyncDeleteModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteModelRequest request = + DeleteModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.deleteModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletemodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModelLRO.java new file mode 100644 index 000000000..eba522fa0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/AsyncDeleteModelLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletemodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DeleteModelRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteModelLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteModelLRO(); + } + + public static void asyncDeleteModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteModelRequest request = + DeleteModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + OperationFuture future = + autoMlClient.deleteModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletemodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModel.java new file mode 100644 index 000000000..783e719e3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletemodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DeleteModelRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeleteModel { + + public static void main(String[] args) throws Exception { + syncDeleteModel(); + } + + public static void syncDeleteModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeleteModelRequest request = + DeleteModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + autoMlClient.deleteModelAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletemodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelModelname.java new file mode 100644 index 000000000..c5ab0d057 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelModelname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletemodel_modelname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeleteModelModelname { + + public static void main(String[] args) throws Exception { + syncDeleteModelModelname(); + } + + public static void syncDeleteModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + autoMlClient.deleteModelAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletemodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelString.java new file mode 100644 index 000000000..4a152fcd2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deletemodel/SyncDeleteModelString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deletemodel_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeleteModelString { + + public static void main(String[] args) throws Exception { + syncDeleteModelString(); + } + + public static void syncDeleteModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + autoMlClient.deleteModelAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deletemodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModel.java new file mode 100644 index 000000000..782699cf7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deploymodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DeployModelRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.longrunning.Operation; + +public class AsyncDeployModel { + + public static void main(String[] args) throws Exception { + asyncDeployModel(); + } + + public static void asyncDeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeployModelRequest request = + DeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.deployModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deploymodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModelLRO.java new file mode 100644 index 000000000..6dc3371f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/AsyncDeployModelLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deploymodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DeployModelRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeployModelLRO { + + public static void main(String[] args) throws Exception { + asyncDeployModelLRO(); + } + + public static void asyncDeployModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeployModelRequest request = + DeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + OperationFuture future = + autoMlClient.deployModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deploymodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModel.java new file mode 100644 index 000000000..9d7903c5d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deploymodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DeployModelRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeployModel { + + public static void main(String[] args) throws Exception { + syncDeployModel(); + } + + public static void syncDeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DeployModelRequest request = + DeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + autoMlClient.deployModelAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deploymodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelModelname.java new file mode 100644 index 000000000..099580ef6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelModelname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deploymodel_modelname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeployModelModelname { + + public static void main(String[] args) throws Exception { + syncDeployModelModelname(); + } + + public static void syncDeployModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + autoMlClient.deployModelAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deploymodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelString.java new file mode 100644 index 000000000..9180775f5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/deploymodel/SyncDeployModelString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_deploymodel_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncDeployModelString { + + public static void main(String[] args) throws Exception { + syncDeployModelString(); + } + + public static void syncDeployModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + autoMlClient.deployModelAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_deploymodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportData.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportData.java new file mode 100644 index 000000000..baf2d7e94 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportData.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportdata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ExportDataRequest; +import com.google.cloud.automl.v1beta1.OutputConfig; +import com.google.longrunning.Operation; + +public class AsyncExportData { + + public static void main(String[] args) throws Exception { + asyncExportData(); + } + + public static void asyncExportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportDataRequest request = + ExportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.exportDataCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportdata_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportDataLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportDataLRO.java new file mode 100644 index 000000000..97586825d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/AsyncExportDataLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportdata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ExportDataRequest; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.cloud.automl.v1beta1.OutputConfig; +import com.google.protobuf.Empty; + +public class AsyncExportDataLRO { + + public static void main(String[] args) throws Exception { + asyncExportDataLRO(); + } + + public static void asyncExportDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportDataRequest request = + ExportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.exportDataOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportdata_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportData.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportData.java new file mode 100644 index 000000000..e32586d33 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportData.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportdata_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ExportDataRequest; +import com.google.cloud.automl.v1beta1.OutputConfig; +import com.google.protobuf.Empty; + +public class SyncExportData { + + public static void main(String[] args) throws Exception { + syncExportData(); + } + + public static void syncExportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportDataRequest request = + ExportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .build(); + autoMlClient.exportDataAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportdata_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.java new file mode 100644 index 000000000..a55f1c120 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataDatasetnameOutputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportdata_datasetnameoutputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.OutputConfig; +import com.google.protobuf.Empty; + +public class SyncExportDataDatasetnameOutputconfig { + + public static void main(String[] args) throws Exception { + syncExportDataDatasetnameOutputconfig(); + } + + public static void syncExportDataDatasetnameOutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + autoMlClient.exportDataAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportdata_datasetnameoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataStringOutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataStringOutputconfig.java new file mode 100644 index 000000000..d8619efa2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportdata/SyncExportDataStringOutputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportdata_stringoutputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.OutputConfig; +import com.google.protobuf.Empty; + +public class SyncExportDataStringOutputconfig { + + public static void main(String[] args) throws Exception { + syncExportDataStringOutputconfig(); + } + + public static void syncExportDataStringOutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + OutputConfig outputConfig = OutputConfig.newBuilder().build(); + autoMlClient.exportDataAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportdata_stringoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamples.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamples.java new file mode 100644 index 000000000..2589b61c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamples.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportevaluatedexamples_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesOutputConfig; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.longrunning.Operation; + +public class AsyncExportEvaluatedExamples { + + public static void main(String[] args) throws Exception { + asyncExportEvaluatedExamples(); + } + + public static void asyncExportEvaluatedExamples() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportEvaluatedExamplesRequest request = + ExportEvaluatedExamplesRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ExportEvaluatedExamplesOutputConfig.newBuilder().build()) + .build(); + ApiFuture future = + autoMlClient.exportEvaluatedExamplesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportevaluatedexamples_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamplesLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamplesLRO.java new file mode 100644 index 000000000..03010d005 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/AsyncExportEvaluatedExamplesLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportevaluatedexamples_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesOutputConfig; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncExportEvaluatedExamplesLRO { + + public static void main(String[] args) throws Exception { + asyncExportEvaluatedExamplesLRO(); + } + + public static void asyncExportEvaluatedExamplesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportEvaluatedExamplesRequest request = + ExportEvaluatedExamplesRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ExportEvaluatedExamplesOutputConfig.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.exportEvaluatedExamplesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportevaluatedexamples_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamples.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamples.java new file mode 100644 index 000000000..c58557a56 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamples.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportevaluatedexamples_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesOutputConfig; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportEvaluatedExamples { + + public static void main(String[] args) throws Exception { + syncExportEvaluatedExamples(); + } + + public static void syncExportEvaluatedExamples() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportEvaluatedExamplesRequest request = + ExportEvaluatedExamplesRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ExportEvaluatedExamplesOutputConfig.newBuilder().build()) + .build(); + autoMlClient.exportEvaluatedExamplesAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportevaluatedexamples_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesModelnameExportevaluatedexamplesoutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesModelnameExportevaluatedexamplesoutputconfig.java new file mode 100644 index 000000000..e61006f23 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesModelnameExportevaluatedexamplesoutputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportevaluatedexamples_modelnameexportevaluatedexamplesoutputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesOutputConfig; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportEvaluatedExamplesModelnameExportevaluatedexamplesoutputconfig { + + public static void main(String[] args) throws Exception { + syncExportEvaluatedExamplesModelnameExportevaluatedexamplesoutputconfig(); + } + + public static void syncExportEvaluatedExamplesModelnameExportevaluatedexamplesoutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExportEvaluatedExamplesOutputConfig outputConfig = + ExportEvaluatedExamplesOutputConfig.newBuilder().build(); + autoMlClient.exportEvaluatedExamplesAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportevaluatedexamples_modelnameexportevaluatedexamplesoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesStringExportevaluatedexamplesoutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesStringExportevaluatedexamplesoutputconfig.java new file mode 100644 index 000000000..288aeb5bc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportevaluatedexamples/SyncExportEvaluatedExamplesStringExportevaluatedexamplesoutputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportevaluatedexamples_stringexportevaluatedexamplesoutputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportEvaluatedExamplesOutputConfig; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportEvaluatedExamplesStringExportevaluatedexamplesoutputconfig { + + public static void main(String[] args) throws Exception { + syncExportEvaluatedExamplesStringExportevaluatedexamplesoutputconfig(); + } + + public static void syncExportEvaluatedExamplesStringExportevaluatedexamplesoutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + ExportEvaluatedExamplesOutputConfig outputConfig = + ExportEvaluatedExamplesOutputConfig.newBuilder().build(); + autoMlClient.exportEvaluatedExamplesAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportevaluatedexamples_stringexportevaluatedexamplesoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModel.java new file mode 100644 index 000000000..f27af3c19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportModelRequest; +import com.google.cloud.automl.v1beta1.ModelExportOutputConfig; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.longrunning.Operation; + +public class AsyncExportModel { + + public static void main(String[] args) throws Exception { + asyncExportModel(); + } + + public static void asyncExportModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportModelRequest request = + ExportModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ModelExportOutputConfig.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.exportModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportmodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModelLRO.java new file mode 100644 index 000000000..20bb55a2c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/AsyncExportModelLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportModelRequest; +import com.google.cloud.automl.v1beta1.ModelExportOutputConfig; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncExportModelLRO { + + public static void main(String[] args) throws Exception { + asyncExportModelLRO(); + } + + public static void asyncExportModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportModelRequest request = + ExportModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ModelExportOutputConfig.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.exportModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportmodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModel.java new file mode 100644 index 000000000..4da8536a2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportmodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ExportModelRequest; +import com.google.cloud.automl.v1beta1.ModelExportOutputConfig; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportModel { + + public static void main(String[] args) throws Exception { + syncExportModel(); + } + + public static void syncExportModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ExportModelRequest request = + ExportModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setOutputConfig(ModelExportOutputConfig.newBuilder().build()) + .build(); + autoMlClient.exportModelAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.java new file mode 100644 index 000000000..f38475b28 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelModelnameModelexportoutputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportmodel_modelnamemodelexportoutputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelExportOutputConfig; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportModelModelnameModelexportoutputconfig { + + public static void main(String[] args) throws Exception { + syncExportModelModelnameModelexportoutputconfig(); + } + + public static void syncExportModelModelnameModelexportoutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + autoMlClient.exportModelAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportmodel_modelnamemodelexportoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.java new file mode 100644 index 000000000..cead70aad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/exportmodel/SyncExportModelStringModelexportoutputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_exportmodel_stringmodelexportoutputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelExportOutputConfig; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncExportModelStringModelexportoutputconfig { + + public static void main(String[] args) throws Exception { + syncExportModelStringModelexportoutputconfig(); + } + + public static void syncExportModelStringModelexportoutputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + ModelExportOutputConfig outputConfig = ModelExportOutputConfig.newBuilder().build(); + autoMlClient.exportModelAsync(name, outputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_exportmodel_stringmodelexportoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/AsyncGetAnnotationSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/AsyncGetAnnotationSpec.java new file mode 100644 index 000000000..84b6d0ce6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/AsyncGetAnnotationSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getannotationspec_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AnnotationSpec; +import com.google.cloud.automl.v1beta1.AnnotationSpecName; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetAnnotationSpecRequest; + +public class AsyncGetAnnotationSpec { + + public static void main(String[] args) throws Exception { + asyncGetAnnotationSpec(); + } + + public static void asyncGetAnnotationSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetAnnotationSpecRequest request = + GetAnnotationSpecRequest.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .build(); + ApiFuture future = + autoMlClient.getAnnotationSpecCallable().futureCall(request); + // Do something. + AnnotationSpec response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_getannotationspec_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpec.java new file mode 100644 index 000000000..13a2688db --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getannotationspec_sync] +import com.google.cloud.automl.v1beta1.AnnotationSpec; +import com.google.cloud.automl.v1beta1.AnnotationSpecName; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetAnnotationSpecRequest; + +public class SyncGetAnnotationSpec { + + public static void main(String[] args) throws Exception { + syncGetAnnotationSpec(); + } + + public static void syncGetAnnotationSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetAnnotationSpecRequest request = + GetAnnotationSpecRequest.newBuilder() + .setName( + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString()) + .build(); + AnnotationSpec response = autoMlClient.getAnnotationSpec(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_getannotationspec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.java new file mode 100644 index 000000000..cf629b7a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecAnnotationspecname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getannotationspec_annotationspecname_sync] +import com.google.cloud.automl.v1beta1.AnnotationSpec; +import com.google.cloud.automl.v1beta1.AnnotationSpecName; +import com.google.cloud.automl.v1beta1.AutoMlClient; + +public class SyncGetAnnotationSpecAnnotationspecname { + + public static void main(String[] args) throws Exception { + syncGetAnnotationSpecAnnotationspecname(); + } + + public static void syncGetAnnotationSpecAnnotationspecname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + AnnotationSpecName name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]"); + AnnotationSpec response = autoMlClient.getAnnotationSpec(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getannotationspec_annotationspecname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecString.java new file mode 100644 index 000000000..58fbd4cce --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getannotationspec/SyncGetAnnotationSpecString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getannotationspec_string_sync] +import com.google.cloud.automl.v1beta1.AnnotationSpec; +import com.google.cloud.automl.v1beta1.AnnotationSpecName; +import com.google.cloud.automl.v1beta1.AutoMlClient; + +public class SyncGetAnnotationSpecString { + + public static void main(String[] args) throws Exception { + syncGetAnnotationSpecString(); + } + + public static void syncGetAnnotationSpecString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = + AnnotationSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[ANNOTATION_SPEC]") + .toString(); + AnnotationSpec response = autoMlClient.getAnnotationSpec(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getannotationspec_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/AsyncGetColumnSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/AsyncGetColumnSpec.java new file mode 100644 index 000000000..225efa244 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/AsyncGetColumnSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getcolumnspec_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.ColumnSpecName; +import com.google.cloud.automl.v1beta1.GetColumnSpecRequest; +import com.google.protobuf.FieldMask; + +public class AsyncGetColumnSpec { + + public static void main(String[] args) throws Exception { + asyncGetColumnSpec(); + } + + public static void asyncGetColumnSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetColumnSpecRequest request = + GetColumnSpecRequest.newBuilder() + .setName( + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.getColumnSpecCallable().futureCall(request); + // Do something. + ColumnSpec response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_getcolumnspec_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpec.java new file mode 100644 index 000000000..7513c419f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getcolumnspec_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.ColumnSpecName; +import com.google.cloud.automl.v1beta1.GetColumnSpecRequest; +import com.google.protobuf.FieldMask; + +public class SyncGetColumnSpec { + + public static void main(String[] args) throws Exception { + syncGetColumnSpec(); + } + + public static void syncGetColumnSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetColumnSpecRequest request = + GetColumnSpecRequest.newBuilder() + .setName( + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .build(); + ColumnSpec response = autoMlClient.getColumnSpec(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_getcolumnspec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecColumnspecname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecColumnspecname.java new file mode 100644 index 000000000..8b890ee63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecColumnspecname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getcolumnspec_columnspecname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.ColumnSpecName; + +public class SyncGetColumnSpecColumnspecname { + + public static void main(String[] args) throws Exception { + syncGetColumnSpecColumnspecname(); + } + + public static void syncGetColumnSpecColumnspecname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ColumnSpecName name = + ColumnSpecName.of( + "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]"); + ColumnSpec response = autoMlClient.getColumnSpec(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getcolumnspec_columnspecname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecString.java new file mode 100644 index 000000000..f8020d79a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getcolumnspec/SyncGetColumnSpecString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getcolumnspec_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.ColumnSpecName; + +public class SyncGetColumnSpecString { + + public static void main(String[] args) throws Exception { + syncGetColumnSpecString(); + } + + public static void syncGetColumnSpecString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = + ColumnSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]") + .toString(); + ColumnSpec response = autoMlClient.getColumnSpec(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getcolumnspec_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/AsyncGetDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/AsyncGetDataset.java new file mode 100644 index 000000000..0b513e50d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/AsyncGetDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getdataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.GetDatasetRequest; + +public class AsyncGetDataset { + + public static void main(String[] args) throws Exception { + asyncGetDataset(); + } + + public static void asyncGetDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetDatasetRequest request = + GetDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + ApiFuture future = autoMlClient.getDatasetCallable().futureCall(request); + // Do something. + Dataset response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_getdataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDataset.java new file mode 100644 index 000000000..0b70fa045 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getdataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.GetDatasetRequest; + +public class SyncGetDataset { + + public static void main(String[] args) throws Exception { + syncGetDataset(); + } + + public static void syncGetDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetDatasetRequest request = + GetDatasetRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .build(); + Dataset response = autoMlClient.getDataset(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_getdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetDatasetname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetDatasetname.java new file mode 100644 index 000000000..89e7792e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetDatasetname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getdataset_datasetname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.DatasetName; + +public class SyncGetDatasetDatasetname { + + public static void main(String[] args) throws Exception { + syncGetDatasetDatasetname(); + } + + public static void syncGetDatasetDatasetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + Dataset response = autoMlClient.getDataset(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getdataset_datasetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetString.java new file mode 100644 index 000000000..012bf9a27 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getdataset/SyncGetDatasetString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getdataset_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.DatasetName; + +public class SyncGetDatasetString { + + public static void main(String[] args) throws Exception { + syncGetDatasetString(); + } + + public static void syncGetDatasetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + Dataset response = autoMlClient.getDataset(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getdataset_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/AsyncGetModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/AsyncGetModel.java new file mode 100644 index 000000000..3c5e8ab7d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/AsyncGetModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetModelRequest; +import com.google.cloud.automl.v1beta1.Model; +import com.google.cloud.automl.v1beta1.ModelName; + +public class AsyncGetModel { + + public static void main(String[] args) throws Exception { + asyncGetModel(); + } + + public static void asyncGetModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelRequest request = + GetModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.getModelCallable().futureCall(request); + // Do something. + Model response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModel.java new file mode 100644 index 000000000..24b6aaf74 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetModelRequest; +import com.google.cloud.automl.v1beta1.Model; +import com.google.cloud.automl.v1beta1.ModelName; + +public class SyncGetModel { + + public static void main(String[] args) throws Exception { + syncGetModel(); + } + + public static void syncGetModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelRequest request = + GetModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + Model response = autoMlClient.getModel(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelModelname.java new file mode 100644 index 000000000..821b75486 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelModelname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodel_modelname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Model; +import com.google.cloud.automl.v1beta1.ModelName; + +public class SyncGetModelModelname { + + public static void main(String[] args) throws Exception { + syncGetModelModelname(); + } + + public static void syncGetModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + Model response = autoMlClient.getModel(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelString.java new file mode 100644 index 000000000..22388a8c8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodel/SyncGetModelString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodel_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Model; +import com.google.cloud.automl.v1beta1.ModelName; + +public class SyncGetModelString { + + public static void main(String[] args) throws Exception { + syncGetModelString(); + } + + public static void syncGetModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + Model response = autoMlClient.getModel(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.java new file mode 100644 index 000000000..374411040 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/AsyncGetModelEvaluation.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodelevaluation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetModelEvaluationRequest; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelEvaluationName; + +public class AsyncGetModelEvaluation { + + public static void main(String[] args) throws Exception { + asyncGetModelEvaluation(); + } + + public static void asyncGetModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelEvaluationRequest request = + GetModelEvaluationRequest.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .build(); + ApiFuture future = + autoMlClient.getModelEvaluationCallable().futureCall(request); + // Do something. + ModelEvaluation response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodelevaluation_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluation.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluation.java new file mode 100644 index 000000000..e6bcb9dce --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluation.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodelevaluation_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetModelEvaluationRequest; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelEvaluationName; + +public class SyncGetModelEvaluation { + + public static void main(String[] args) throws Exception { + syncGetModelEvaluation(); + } + + public static void syncGetModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetModelEvaluationRequest request = + GetModelEvaluationRequest.newBuilder() + .setName( + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString()) + .build(); + ModelEvaluation response = autoMlClient.getModelEvaluation(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodelevaluation_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.java new file mode 100644 index 000000000..6d4181f27 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationModelevaluationname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodelevaluation_modelevaluationname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelEvaluationName; + +public class SyncGetModelEvaluationModelevaluationname { + + public static void main(String[] args) throws Exception { + syncGetModelEvaluationModelevaluationname(); + } + + public static void syncGetModelEvaluationModelevaluationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelEvaluationName name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"); + ModelEvaluation response = autoMlClient.getModelEvaluation(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodelevaluation_modelevaluationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.java new file mode 100644 index 000000000..42097609a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/getmodelevaluation/SyncGetModelEvaluationString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_getmodelevaluation_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelEvaluationName; + +public class SyncGetModelEvaluationString { + + public static void main(String[] args) throws Exception { + syncGetModelEvaluationString(); + } + + public static void syncGetModelEvaluationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = + ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]") + .toString(); + ModelEvaluation response = autoMlClient.getModelEvaluation(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_getmodelevaluation_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/AsyncGetTableSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/AsyncGetTableSpec.java new file mode 100644 index 000000000..000f67567 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/AsyncGetTableSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_gettablespec_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetTableSpecRequest; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.cloud.automl.v1beta1.TableSpecName; +import com.google.protobuf.FieldMask; + +public class AsyncGetTableSpec { + + public static void main(String[] args) throws Exception { + asyncGetTableSpec(); + } + + public static void asyncGetTableSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetTableSpecRequest request = + GetTableSpecRequest.newBuilder() + .setName( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]") + .toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.getTableSpecCallable().futureCall(request); + // Do something. + TableSpec response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_gettablespec_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpec.java new file mode 100644 index 000000000..e7b7153e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_gettablespec_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.GetTableSpecRequest; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.cloud.automl.v1beta1.TableSpecName; +import com.google.protobuf.FieldMask; + +public class SyncGetTableSpec { + + public static void main(String[] args) throws Exception { + syncGetTableSpec(); + } + + public static void syncGetTableSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + GetTableSpecRequest request = + GetTableSpecRequest.newBuilder() + .setName( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]") + .toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .build(); + TableSpec response = autoMlClient.getTableSpec(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_gettablespec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecString.java new file mode 100644 index 000000000..ac2f945d4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_gettablespec_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.cloud.automl.v1beta1.TableSpecName; + +public class SyncGetTableSpecString { + + public static void main(String[] args) throws Exception { + syncGetTableSpecString(); + } + + public static void syncGetTableSpecString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]").toString(); + TableSpec response = autoMlClient.getTableSpec(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_gettablespec_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecTablespecname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecTablespecname.java new file mode 100644 index 000000000..60375ecc9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/gettablespec/SyncGetTableSpecTablespecname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_gettablespec_tablespecname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.cloud.automl.v1beta1.TableSpecName; + +public class SyncGetTableSpecTablespecname { + + public static void main(String[] args) throws Exception { + syncGetTableSpecTablespecname(); + } + + public static void syncGetTableSpecTablespecname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + TableSpecName name = TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]"); + TableSpec response = autoMlClient.getTableSpec(name); + } + } +} +// [END automl_v1beta1_generated_automlclient_gettablespec_tablespecname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportData.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportData.java new file mode 100644 index 000000000..75f4ff83c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportData.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_importdata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ImportDataRequest; +import com.google.cloud.automl.v1beta1.InputConfig; +import com.google.longrunning.Operation; + +public class AsyncImportData { + + public static void main(String[] args) throws Exception { + asyncImportData(); + } + + public static void asyncImportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ImportDataRequest request = + ImportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.importDataCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_importdata_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportDataLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportDataLRO.java new file mode 100644 index 000000000..23450dcb0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/AsyncImportDataLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_importdata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ImportDataRequest; +import com.google.cloud.automl.v1beta1.InputConfig; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncImportDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportDataLRO(); + } + + public static void asyncImportDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ImportDataRequest request = + ImportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + OperationFuture future = + autoMlClient.importDataOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_importdata_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportData.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportData.java new file mode 100644 index 000000000..e57e01fe9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportData.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_importdata_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ImportDataRequest; +import com.google.cloud.automl.v1beta1.InputConfig; +import com.google.protobuf.Empty; + +public class SyncImportData { + + public static void main(String[] args) throws Exception { + syncImportData(); + } + + public static void syncImportData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ImportDataRequest request = + ImportDataRequest.newBuilder() + .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + autoMlClient.importDataAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_importdata_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.java new file mode 100644 index 000000000..90d500b7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataDatasetnameInputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_importdata_datasetnameinputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.InputConfig; +import com.google.protobuf.Empty; + +public class SyncImportDataDatasetnameInputconfig { + + public static void main(String[] args) throws Exception { + syncImportDataDatasetnameInputconfig(); + } + + public static void syncImportDataDatasetnameInputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + InputConfig inputConfig = InputConfig.newBuilder().build(); + autoMlClient.importDataAsync(name, inputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_importdata_datasetnameinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataStringInputconfig.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataStringInputconfig.java new file mode 100644 index 000000000..481b45202 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/importdata/SyncImportDataStringInputconfig.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_importdata_stringinputconfig_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.InputConfig; +import com.google.protobuf.Empty; + +public class SyncImportDataStringInputconfig { + + public static void main(String[] args) throws Exception { + syncImportDataStringInputconfig(); + } + + public static void syncImportDataStringInputconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + InputConfig inputConfig = InputConfig.newBuilder().build(); + autoMlClient.importDataAsync(name, inputConfig).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_importdata_stringinputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecs.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecs.java new file mode 100644 index 000000000..afefd5158 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecs.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listcolumnspecs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.ListColumnSpecsRequest; +import com.google.cloud.automl.v1beta1.TableSpecName; +import com.google.protobuf.FieldMask; + +public class AsyncListColumnSpecs { + + public static void main(String[] args) throws Exception { + asyncListColumnSpecs(); + } + + public static void asyncListColumnSpecs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListColumnSpecsRequest request = + ListColumnSpecsRequest.newBuilder() + .setParent( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]") + .toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + autoMlClient.listColumnSpecsPagedCallable().futureCall(request); + // Do something. + for (ColumnSpec element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listcolumnspecs_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecsPaged.java new file mode 100644 index 000000000..2ac00131c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/AsyncListColumnSpecsPaged.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listcolumnspecs_paged_async] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.ListColumnSpecsRequest; +import com.google.cloud.automl.v1beta1.ListColumnSpecsResponse; +import com.google.cloud.automl.v1beta1.TableSpecName; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +public class AsyncListColumnSpecsPaged { + + public static void main(String[] args) throws Exception { + asyncListColumnSpecsPaged(); + } + + public static void asyncListColumnSpecsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListColumnSpecsRequest request = + ListColumnSpecsRequest.newBuilder() + .setParent( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]") + .toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListColumnSpecsResponse response = autoMlClient.listColumnSpecsCallable().call(request); + for (ColumnSpec element : response.getColumnSpecsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listcolumnspecs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecs.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecs.java new file mode 100644 index 000000000..ffde86309 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecs.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listcolumnspecs_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.ListColumnSpecsRequest; +import com.google.cloud.automl.v1beta1.TableSpecName; +import com.google.protobuf.FieldMask; + +public class SyncListColumnSpecs { + + public static void main(String[] args) throws Exception { + syncListColumnSpecs(); + } + + public static void syncListColumnSpecs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListColumnSpecsRequest request = + ListColumnSpecsRequest.newBuilder() + .setParent( + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]") + .toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ColumnSpec element : autoMlClient.listColumnSpecs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listcolumnspecs_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsString.java new file mode 100644 index 000000000..cf37023bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listcolumnspecs_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.TableSpecName; + +public class SyncListColumnSpecsString { + + public static void main(String[] args) throws Exception { + syncListColumnSpecsString(); + } + + public static void syncListColumnSpecsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]").toString(); + for (ColumnSpec element : autoMlClient.listColumnSpecs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listcolumnspecs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsTablespecname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsTablespecname.java new file mode 100644 index 000000000..9c2b1080e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listcolumnspecs/SyncListColumnSpecsTablespecname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listcolumnspecs_tablespecname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.TableSpecName; + +public class SyncListColumnSpecsTablespecname { + + public static void main(String[] args) throws Exception { + syncListColumnSpecsTablespecname(); + } + + public static void syncListColumnSpecsTablespecname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + TableSpecName parent = + TableSpecName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]"); + for (ColumnSpec element : autoMlClient.listColumnSpecs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listcolumnspecs_tablespecname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasets.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasets.java new file mode 100644 index 000000000..310563c2f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasets.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listdatasets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.ListDatasetsRequest; +import com.google.cloud.automl.v1beta1.LocationName; + +public class AsyncListDatasets { + + public static void main(String[] args) throws Exception { + asyncListDatasets(); + } + + public static void asyncListDatasets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListDatasetsRequest request = + ListDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = autoMlClient.listDatasetsPagedCallable().futureCall(request); + // Do something. + for (Dataset element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listdatasets_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasetsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasetsPaged.java new file mode 100644 index 000000000..73a009f42 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/AsyncListDatasetsPaged.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listdatasets_paged_async] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.ListDatasetsRequest; +import com.google.cloud.automl.v1beta1.ListDatasetsResponse; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListDatasetsPaged { + + public static void main(String[] args) throws Exception { + asyncListDatasetsPaged(); + } + + public static void asyncListDatasetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListDatasetsRequest request = + ListDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListDatasetsResponse response = autoMlClient.listDatasetsCallable().call(request); + for (Dataset element : response.getDatasetsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listdatasets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasets.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasets.java new file mode 100644 index 000000000..ca88dbe36 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasets.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listdatasets_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.ListDatasetsRequest; +import com.google.cloud.automl.v1beta1.LocationName; + +public class SyncListDatasets { + + public static void main(String[] args) throws Exception { + syncListDatasets(); + } + + public static void syncListDatasets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListDatasetsRequest request = + ListDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Dataset element : autoMlClient.listDatasets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listdatasets_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsLocationname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsLocationname.java new file mode 100644 index 000000000..414bae6dd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsLocationname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listdatasets_locationname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.LocationName; + +public class SyncListDatasetsLocationname { + + public static void main(String[] args) throws Exception { + syncListDatasetsLocationname(); + } + + public static void syncListDatasetsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Dataset element : autoMlClient.listDatasets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listdatasets_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsString.java new file mode 100644 index 000000000..d48c4314a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listdatasets/SyncListDatasetsString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listdatasets_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.LocationName; + +public class SyncListDatasetsString { + + public static void main(String[] args) throws Exception { + syncListDatasetsString(); + } + + public static void syncListDatasetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Dataset element : autoMlClient.listDatasets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listdatasets_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluations.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluations.java new file mode 100644 index 000000000..86498f3b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluations.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodelevaluations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelName; + +public class AsyncListModelEvaluations { + + public static void main(String[] args) throws Exception { + asyncListModelEvaluations(); + } + + public static void asyncListModelEvaluations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelEvaluationsRequest request = + ListModelEvaluationsRequest.newBuilder() + .setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + autoMlClient.listModelEvaluationsPagedCallable().futureCall(request); + // Do something. + for (ModelEvaluation element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodelevaluations_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.java new file mode 100644 index 000000000..1eebed015 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/AsyncListModelEvaluationsPaged.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodelevaluations_paged_async] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1beta1.ListModelEvaluationsResponse; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.common.base.Strings; + +public class AsyncListModelEvaluationsPaged { + + public static void main(String[] args) throws Exception { + asyncListModelEvaluationsPaged(); + } + + public static void asyncListModelEvaluationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelEvaluationsRequest request = + ListModelEvaluationsRequest.newBuilder() + .setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListModelEvaluationsResponse response = + autoMlClient.listModelEvaluationsCallable().call(request); + for (ModelEvaluation element : response.getModelEvaluationList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodelevaluations_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluations.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluations.java new file mode 100644 index 000000000..50e19ce09 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluations.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodelevaluations_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ListModelEvaluationsRequest; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelName; + +public class SyncListModelEvaluations { + + public static void main(String[] args) throws Exception { + syncListModelEvaluations(); + } + + public static void syncListModelEvaluations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelEvaluationsRequest request = + ListModelEvaluationsRequest.newBuilder() + .setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ModelEvaluation element : autoMlClient.listModelEvaluations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodelevaluations_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelname.java new file mode 100644 index 000000000..9370c177c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsModelname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodelevaluations_modelname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelName; + +public class SyncListModelEvaluationsModelname { + + public static void main(String[] args) throws Exception { + syncListModelEvaluationsModelname(); + } + + public static void syncListModelEvaluationsModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + for (ModelEvaluation element : autoMlClient.listModelEvaluations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodelevaluations_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsString.java new file mode 100644 index 000000000..1f9d6c2bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodelevaluations/SyncListModelEvaluationsString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodelevaluations_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelEvaluation; +import com.google.cloud.automl.v1beta1.ModelName; + +public class SyncListModelEvaluationsString { + + public static void main(String[] args) throws Exception { + syncListModelEvaluationsString(); + } + + public static void syncListModelEvaluationsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + for (ModelEvaluation element : autoMlClient.listModelEvaluations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodelevaluations_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModels.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModels.java new file mode 100644 index 000000000..e7e1db674 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModels.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodels_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ListModelsRequest; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; + +public class AsyncListModels { + + public static void main(String[] args) throws Exception { + asyncListModels(); + } + + public static void asyncListModels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelsRequest request = + ListModelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = autoMlClient.listModelsPagedCallable().futureCall(request); + // Do something. + for (Model element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodels_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModelsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModelsPaged.java new file mode 100644 index 000000000..5755381d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/AsyncListModelsPaged.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodels_paged_async] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ListModelsRequest; +import com.google.cloud.automl.v1beta1.ListModelsResponse; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; +import com.google.common.base.Strings; + +public class AsyncListModelsPaged { + + public static void main(String[] args) throws Exception { + asyncListModelsPaged(); + } + + public static void asyncListModelsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelsRequest request = + ListModelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListModelsResponse response = autoMlClient.listModelsCallable().call(request); + for (Model element : response.getModelList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodels_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModels.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModels.java new file mode 100644 index 000000000..0bc01a629 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModels.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodels_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ListModelsRequest; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; + +public class SyncListModels { + + public static void main(String[] args) throws Exception { + syncListModels(); + } + + public static void syncListModels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListModelsRequest request = + ListModelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Model element : autoMlClient.listModels(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodels_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsLocationname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsLocationname.java new file mode 100644 index 000000000..088944599 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsLocationname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodels_locationname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; + +public class SyncListModelsLocationname { + + public static void main(String[] args) throws Exception { + syncListModelsLocationname(); + } + + public static void syncListModelsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Model element : autoMlClient.listModels(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodels_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsString.java new file mode 100644 index 000000000..4bc92d00a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listmodels/SyncListModelsString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listmodels_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.LocationName; +import com.google.cloud.automl.v1beta1.Model; + +public class SyncListModelsString { + + public static void main(String[] args) throws Exception { + syncListModelsString(); + } + + public static void syncListModelsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Model element : autoMlClient.listModels(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listmodels_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecs.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecs.java new file mode 100644 index 000000000..6dc6b6533 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecs.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listtablespecs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ListTableSpecsRequest; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.protobuf.FieldMask; + +public class AsyncListTableSpecs { + + public static void main(String[] args) throws Exception { + asyncListTableSpecs(); + } + + public static void asyncListTableSpecs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListTableSpecsRequest request = + ListTableSpecsRequest.newBuilder() + .setParent(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = autoMlClient.listTableSpecsPagedCallable().futureCall(request); + // Do something. + for (TableSpec element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listtablespecs_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecsPaged.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecsPaged.java new file mode 100644 index 000000000..6f32d59ef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/AsyncListTableSpecsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listtablespecs_paged_async] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ListTableSpecsRequest; +import com.google.cloud.automl.v1beta1.ListTableSpecsResponse; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; + +public class AsyncListTableSpecsPaged { + + public static void main(String[] args) throws Exception { + asyncListTableSpecsPaged(); + } + + public static void asyncListTableSpecsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListTableSpecsRequest request = + ListTableSpecsRequest.newBuilder() + .setParent(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListTableSpecsResponse response = autoMlClient.listTableSpecsCallable().call(request); + for (TableSpec element : response.getTableSpecsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listtablespecs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecs.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecs.java new file mode 100644 index 000000000..678e0125a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecs.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listtablespecs_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.ListTableSpecsRequest; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.protobuf.FieldMask; + +public class SyncListTableSpecs { + + public static void main(String[] args) throws Exception { + syncListTableSpecs(); + } + + public static void syncListTableSpecs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ListTableSpecsRequest request = + ListTableSpecsRequest.newBuilder() + .setParent(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (TableSpec element : autoMlClient.listTableSpecs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listtablespecs_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsDatasetname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsDatasetname.java new file mode 100644 index 000000000..dfe850f87 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsDatasetname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listtablespecs_datasetname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.TableSpec; + +public class SyncListTableSpecsDatasetname { + + public static void main(String[] args) throws Exception { + syncListTableSpecsDatasetname(); + } + + public static void syncListTableSpecsDatasetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + DatasetName parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]"); + for (TableSpec element : autoMlClient.listTableSpecs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listtablespecs_datasetname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsString.java new file mode 100644 index 000000000..a88870359 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/listtablespecs/SyncListTableSpecsString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_listtablespecs_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.DatasetName; +import com.google.cloud.automl.v1beta1.TableSpec; + +public class SyncListTableSpecsString { + + public static void main(String[] args) throws Exception { + syncListTableSpecsString(); + } + + public static void syncListTableSpecsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString(); + for (TableSpec element : autoMlClient.listTableSpecs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END automl_v1beta1_generated_automlclient_listtablespecs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModel.java new file mode 100644 index 000000000..62de941cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_undeploymodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.UndeployModelRequest; +import com.google.longrunning.Operation; + +public class AsyncUndeployModel { + + public static void main(String[] args) throws Exception { + asyncUndeployModel(); + } + + public static void asyncUndeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UndeployModelRequest request = + UndeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + ApiFuture future = autoMlClient.undeployModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_undeploymodel_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModelLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModelLRO.java new file mode 100644 index 000000000..74d388164 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/AsyncUndeployModelLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_undeploymodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.cloud.automl.v1beta1.UndeployModelRequest; +import com.google.protobuf.Empty; + +public class AsyncUndeployModelLRO { + + public static void main(String[] args) throws Exception { + asyncUndeployModelLRO(); + } + + public static void asyncUndeployModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UndeployModelRequest request = + UndeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + OperationFuture future = + autoMlClient.undeployModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_undeploymodel_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModel.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModel.java new file mode 100644 index 000000000..541c084b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModel.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_undeploymodel_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.UndeployModelRequest; +import com.google.protobuf.Empty; + +public class SyncUndeployModel { + + public static void main(String[] args) throws Exception { + syncUndeployModel(); + } + + public static void syncUndeployModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UndeployModelRequest request = + UndeployModelRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .build(); + autoMlClient.undeployModelAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_undeploymodel_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelModelname.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelModelname.java new file mode 100644 index 000000000..8ad13beec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelModelname.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_undeploymodel_modelname_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncUndeployModelModelname { + + public static void main(String[] args) throws Exception { + syncUndeployModelModelname(); + } + + public static void syncUndeployModelModelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + autoMlClient.undeployModelAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_undeploymodel_modelname_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelString.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelString.java new file mode 100644 index 000000000..981b67392 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/undeploymodel/SyncUndeployModelString.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_undeploymodel_string_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.protobuf.Empty; + +public class SyncUndeployModelString { + + public static void main(String[] args) throws Exception { + syncUndeployModelString(); + } + + public static void syncUndeployModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + autoMlClient.undeployModelAsync(name).get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_undeploymodel_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/AsyncUpdateColumnSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/AsyncUpdateColumnSpec.java new file mode 100644 index 000000000..82b4ab005 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/AsyncUpdateColumnSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatecolumnspec_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.UpdateColumnSpecRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateColumnSpec { + + public static void main(String[] args) throws Exception { + asyncUpdateColumnSpec(); + } + + public static void asyncUpdateColumnSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateColumnSpecRequest request = + UpdateColumnSpecRequest.newBuilder() + .setColumnSpec(ColumnSpec.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.updateColumnSpecCallable().futureCall(request); + // Do something. + ColumnSpec response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatecolumnspec_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpec.java new file mode 100644 index 000000000..52b09aa8e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatecolumnspec_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; +import com.google.cloud.automl.v1beta1.UpdateColumnSpecRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateColumnSpec { + + public static void main(String[] args) throws Exception { + syncUpdateColumnSpec(); + } + + public static void syncUpdateColumnSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateColumnSpecRequest request = + UpdateColumnSpecRequest.newBuilder() + .setColumnSpec(ColumnSpec.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ColumnSpec response = autoMlClient.updateColumnSpec(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatecolumnspec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpecColumnspec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpecColumnspec.java new file mode 100644 index 000000000..167e06c16 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatecolumnspec/SyncUpdateColumnSpecColumnspec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatecolumnspec_columnspec_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.ColumnSpec; + +public class SyncUpdateColumnSpecColumnspec { + + public static void main(String[] args) throws Exception { + syncUpdateColumnSpecColumnspec(); + } + + public static void syncUpdateColumnSpecColumnspec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + ColumnSpec columnSpec = ColumnSpec.newBuilder().build(); + ColumnSpec response = autoMlClient.updateColumnSpec(columnSpec); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatecolumnspec_columnspec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/AsyncUpdateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/AsyncUpdateDataset.java new file mode 100644 index 000000000..493efac6a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/AsyncUpdateDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatedataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.UpdateDatasetRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDataset { + + public static void main(String[] args) throws Exception { + asyncUpdateDataset(); + } + + public static void asyncUpdateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateDatasetRequest request = + UpdateDatasetRequest.newBuilder() + .setDataset(Dataset.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.updateDatasetCallable().futureCall(request); + // Do something. + Dataset response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatedataset_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDataset.java new file mode 100644 index 000000000..ffbd37eb8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatedataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; +import com.google.cloud.automl.v1beta1.UpdateDatasetRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDataset { + + public static void main(String[] args) throws Exception { + syncUpdateDataset(); + } + + public static void syncUpdateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateDatasetRequest request = + UpdateDatasetRequest.newBuilder() + .setDataset(Dataset.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Dataset response = autoMlClient.updateDataset(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatedataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDatasetDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDatasetDataset.java new file mode 100644 index 000000000..dd79254df --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatedataset/SyncUpdateDatasetDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatedataset_dataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.Dataset; + +public class SyncUpdateDatasetDataset { + + public static void main(String[] args) throws Exception { + syncUpdateDatasetDataset(); + } + + public static void syncUpdateDatasetDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + Dataset dataset = Dataset.newBuilder().build(); + Dataset response = autoMlClient.updateDataset(dataset); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatedataset_dataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/AsyncUpdateTableSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/AsyncUpdateTableSpec.java new file mode 100644 index 000000000..7fb29f4d7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/AsyncUpdateTableSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatetablespec_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.cloud.automl.v1beta1.UpdateTableSpecRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateTableSpec { + + public static void main(String[] args) throws Exception { + asyncUpdateTableSpec(); + } + + public static void asyncUpdateTableSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateTableSpecRequest request = + UpdateTableSpecRequest.newBuilder() + .setTableSpec(TableSpec.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = autoMlClient.updateTableSpecCallable().futureCall(request); + // Do something. + TableSpec response = future.get(); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatetablespec_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpec.java new file mode 100644 index 000000000..32d47ca25 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatetablespec_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.TableSpec; +import com.google.cloud.automl.v1beta1.UpdateTableSpecRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateTableSpec { + + public static void main(String[] args) throws Exception { + syncUpdateTableSpec(); + } + + public static void syncUpdateTableSpec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + UpdateTableSpecRequest request = + UpdateTableSpecRequest.newBuilder() + .setTableSpec(TableSpec.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + TableSpec response = autoMlClient.updateTableSpec(request); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatetablespec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpecTablespec.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpecTablespec.java new file mode 100644 index 000000000..7819c3eb0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlclient/updatetablespec/SyncUpdateTableSpecTablespec.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlclient_updatetablespec_tablespec_sync] +import com.google.cloud.automl.v1beta1.AutoMlClient; +import com.google.cloud.automl.v1beta1.TableSpec; + +public class SyncUpdateTableSpecTablespec { + + public static void main(String[] args) throws Exception { + syncUpdateTableSpecTablespec(); + } + + public static void syncUpdateTableSpecTablespec() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AutoMlClient autoMlClient = AutoMlClient.create()) { + TableSpec tableSpec = TableSpec.newBuilder().build(); + TableSpec response = autoMlClient.updateTableSpec(tableSpec); + } + } +} +// [END automl_v1beta1_generated_automlclient_updatetablespec_tablespec_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlsettings/createdataset/SyncCreateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlsettings/createdataset/SyncCreateDataset.java new file mode 100644 index 000000000..35f9420c9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/automlsettings/createdataset/SyncCreateDataset.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_automlsettings_createdataset_sync] +import com.google.cloud.automl.v1beta1.AutoMlSettings; +import java.time.Duration; + +public class SyncCreateDataset { + + public static void main(String[] args) throws Exception { + syncCreateDataset(); + } + + public static void syncCreateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AutoMlSettings.Builder autoMlSettingsBuilder = AutoMlSettings.newBuilder(); + autoMlSettingsBuilder + .createDatasetSettings() + .setRetrySettings( + autoMlSettingsBuilder + .createDatasetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AutoMlSettings autoMlSettings = autoMlSettingsBuilder.build(); + } +} +// [END automl_v1beta1_generated_automlsettings_createdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredict.java new file mode 100644 index 000000000..675b2ea62 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredict.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_batchpredict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.BatchPredictInputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictRequest; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import com.google.longrunning.Operation; +import java.util.HashMap; + +public class AsyncBatchPredict { + + public static void main(String[] args) throws Exception { + asyncBatchPredict(); + } + + public static void asyncBatchPredict() 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()) { + BatchPredictRequest request = + BatchPredictRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setInputConfig(BatchPredictInputConfig.newBuilder().build()) + .setOutputConfig(BatchPredictOutputConfig.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.batchPredictCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_batchpredict_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.java new file mode 100644 index 000000000..2f4a3683d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/AsyncBatchPredictLRO.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_batchpredict_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.automl.v1beta1.BatchPredictInputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictRequest; +import com.google.cloud.automl.v1beta1.BatchPredictResult; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.OperationMetadata; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import java.util.HashMap; + +public class AsyncBatchPredictLRO { + + public static void main(String[] args) throws Exception { + asyncBatchPredictLRO(); + } + + public static void asyncBatchPredictLRO() 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()) { + BatchPredictRequest request = + BatchPredictRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setInputConfig(BatchPredictInputConfig.newBuilder().build()) + .setOutputConfig(BatchPredictOutputConfig.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + OperationFuture future = + predictionServiceClient.batchPredictOperationCallable().futureCall(request); + // Do something. + BatchPredictResult response = future.get(); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_batchpredict_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredict.java new file mode 100644 index 000000000..41be75ea9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredict.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_batchpredict_sync] +import com.google.cloud.automl.v1beta1.BatchPredictInputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictRequest; +import com.google.cloud.automl.v1beta1.BatchPredictResult; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import java.util.HashMap; + +public class SyncBatchPredict { + + public static void main(String[] args) throws Exception { + syncBatchPredict(); + } + + public static void syncBatchPredict() 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()) { + BatchPredictRequest request = + BatchPredictRequest.newBuilder() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setInputConfig(BatchPredictInputConfig.newBuilder().build()) + .setOutputConfig(BatchPredictOutputConfig.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + BatchPredictResult response = predictionServiceClient.batchPredictAsync(request).get(); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_batchpredict_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java new file mode 100644 index 000000000..d57f35648 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_batchpredict_modelnamebatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] +import com.google.cloud.automl.v1beta1.BatchPredictInputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictResult; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public +class SyncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring { + + public static void main(String[] args) throws Exception { + syncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring(); + } + + public static void + syncBatchPredictModelnameBatchpredictinputconfigBatchpredictoutputconfigMapstringstring() + 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()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + BatchPredictResult response = + predictionServiceClient.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_batchpredict_modelnamebatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.java new file mode 100644 index 000000000..fe9ec5593 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/batchpredict/SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_batchpredict_stringbatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] +import com.google.cloud.automl.v1beta1.BatchPredictInputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig; +import com.google.cloud.automl.v1beta1.BatchPredictResult; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring { + + public static void main(String[] args) throws Exception { + syncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring(); + } + + public static void + syncBatchPredictStringBatchpredictinputconfigBatchpredictoutputconfigMapstringstring() + 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()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + BatchPredictInputConfig inputConfig = BatchPredictInputConfig.newBuilder().build(); + BatchPredictOutputConfig outputConfig = BatchPredictOutputConfig.newBuilder().build(); + Map params = new HashMap<>(); + BatchPredictResult response = + predictionServiceClient.batchPredictAsync(name, inputConfig, outputConfig, params).get(); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_batchpredict_stringbatchpredictinputconfigbatchpredictoutputconfigmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..48ea3c8f7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import com.google.cloud.automl.v1beta1.PredictionServiceSettings; +import com.google.cloud.automl.v1beta1.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 automl_v1beta1_generated_predictionserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..e5f5f839d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import com.google.cloud.automl.v1beta1.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 automl_v1beta1_generated_predictionserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..be8eedc7d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_create_setendpoint_sync] +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import com.google.cloud.automl.v1beta1.PredictionServiceSettings; +import com.google.cloud.automl.v1beta1.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 automl_v1beta1_generated_predictionserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/AsyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/AsyncPredict.java new file mode 100644 index 000000000..a69475f0c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/AsyncPredict.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_predict_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.automl.v1beta1.ExamplePayload; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictRequest; +import com.google.cloud.automl.v1beta1.PredictResponse; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +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() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setPayload(ExamplePayload.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + ApiFuture future = + predictionServiceClient.predictCallable().futureCall(request); + // Do something. + PredictResponse response = future.get(); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_predict_async] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredict.java new file mode 100644 index 000000000..a3d64d92b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_predict_sync] +import com.google.cloud.automl.v1beta1.ExamplePayload; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictRequest; +import com.google.cloud.automl.v1beta1.PredictResponse; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +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() + .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString()) + .setPayload(ExamplePayload.newBuilder().build()) + .putAllParams(new HashMap()) + .build(); + PredictResponse response = predictionServiceClient.predict(request); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.java new file mode 100644 index 000000000..abea7e7b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictModelnameExamplepayloadMapstringstring.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_predict_modelnameexamplepayloadmapstringstring_sync] +import com.google.cloud.automl.v1beta1.ExamplePayload; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictResponse; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncPredictModelnameExamplepayloadMapstringstring { + + public static void main(String[] args) throws Exception { + syncPredictModelnameExamplepayloadMapstringstring(); + } + + public static void syncPredictModelnameExamplepayloadMapstringstring() 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()) { + ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]"); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + PredictResponse response = predictionServiceClient.predict(name, payload, params); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_predict_modelnameexamplepayloadmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.java new file mode 100644 index 000000000..aa87f7171 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionserviceclient/predict/SyncPredictStringExamplepayloadMapstringstring.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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionserviceclient_predict_stringexamplepayloadmapstringstring_sync] +import com.google.cloud.automl.v1beta1.ExamplePayload; +import com.google.cloud.automl.v1beta1.ModelName; +import com.google.cloud.automl.v1beta1.PredictResponse; +import com.google.cloud.automl.v1beta1.PredictionServiceClient; +import java.util.HashMap; +import java.util.Map; + +public class SyncPredictStringExamplepayloadMapstringstring { + + public static void main(String[] args) throws Exception { + syncPredictStringExamplepayloadMapstringstring(); + } + + public static void syncPredictStringExamplepayloadMapstringstring() 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()) { + String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString(); + ExamplePayload payload = ExamplePayload.newBuilder().build(); + Map params = new HashMap<>(); + PredictResponse response = predictionServiceClient.predict(name, payload, params); + } + } +} +// [END automl_v1beta1_generated_predictionserviceclient_predict_stringexamplepayloadmapstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionservicesettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/predictionservicesettings/predict/SyncPredict.java new file mode 100644 index 000000000..eb9046eb7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/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.automl.v1beta1.samples; + +// [START automl_v1beta1_generated_predictionservicesettings_predict_sync] +import com.google.cloud.automl.v1beta1.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 automl_v1beta1_generated_predictionservicesettings_predict_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/stub/automlstubsettings/createdataset/SyncCreateDataset.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/stub/automlstubsettings/createdataset/SyncCreateDataset.java new file mode 100644 index 000000000..be3b37c41 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/stub/automlstubsettings/createdataset/SyncCreateDataset.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.automl.v1beta1.stub.samples; + +// [START automl_v1beta1_generated_automlstubsettings_createdataset_sync] +import com.google.cloud.automl.v1beta1.stub.AutoMlStubSettings; +import java.time.Duration; + +public class SyncCreateDataset { + + public static void main(String[] args) throws Exception { + syncCreateDataset(); + } + + public static void syncCreateDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AutoMlStubSettings.Builder autoMlSettingsBuilder = AutoMlStubSettings.newBuilder(); + autoMlSettingsBuilder + .createDatasetSettings() + .setRetrySettings( + autoMlSettingsBuilder + .createDatasetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AutoMlStubSettings autoMlSettings = autoMlSettingsBuilder.build(); + } +} +// [END automl_v1beta1_generated_automlstubsettings_createdataset_sync] diff --git a/samples/snippets/generated/com/google/cloud/automl/v1beta1/stub/predictionservicestubsettings/predict/SyncPredict.java b/samples/snippets/generated/com/google/cloud/automl/v1beta1/stub/predictionservicestubsettings/predict/SyncPredict.java new file mode 100644 index 000000000..75f550bd3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/automl/v1beta1/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.automl.v1beta1.stub.samples; + +// [START automl_v1beta1_generated_predictionservicestubsettings_predict_sync] +import com.google.cloud.automl.v1beta1.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 automl_v1beta1_generated_predictionservicestubsettings_predict_sync]