From 1b019ad72c792e10ab0c437bf4dc7eceba42b393 Mon Sep 17 00:00:00 2001 From: Torry Yang Date: Fri, 4 Oct 2019 15:10:55 -0700 Subject: [PATCH] feat: Introduce Cloud AutoML V1 client (#2367) * generate v1 * temp namespace fix * less regex code * metadata changes --- AutoMl/README.md | 4 +- AutoMl/metadata/V1/AnnotationPayload.php | 40 + AutoMl/metadata/V1/DataItems.php | 46 + AutoMl/metadata/V1/Dataset.php | 49 + AutoMl/metadata/V1/Io.php | 45 + AutoMl/metadata/V1/Model.php | 54 + AutoMl/metadata/V1/ModelEvaluation.php | 45 + AutoMl/metadata/V1/Operations.php | 64 + AutoMl/metadata/V1/PredictionService.php | 67 + AutoMl/metadata/V1/Service.php | 175 ++ AutoMl/metadata/V1/Translation.php | 48 + AutoMl/src/V1/AnnotationPayload.php | 70 + AutoMl/src/V1/AutoMlClient.php | 38 + AutoMl/src/V1/AutoMlGrpcClient.php | 259 +++ AutoMl/src/V1/CreateDatasetRequest.php | 101 ++ .../src/V1/CreateModelOperationMetadata.php | 33 + AutoMl/src/V1/CreateModelRequest.php | 101 ++ AutoMl/src/V1/Dataset.php | 353 ++++ AutoMl/src/V1/DeleteDatasetRequest.php | 67 + AutoMl/src/V1/DeleteModelRequest.php | 67 + AutoMl/src/V1/DeleteOperationMetadata.php | 33 + AutoMl/src/V1/ExamplePayload.php | 70 + AutoMl/src/V1/ExportDataRequest.php | 101 ++ AutoMl/src/V1/Gapic/AutoMlGapicClient.php | 1425 +++++++++++++++ .../V1/Gapic/PredictionServiceGapicClient.php | 326 ++++ AutoMl/src/V1/GcsDestination.php | 87 + AutoMl/src/V1/GcsSource.php | 75 + AutoMl/src/V1/GetDatasetRequest.php | 67 + AutoMl/src/V1/GetModelEvaluationRequest.php | 67 + AutoMl/src/V1/GetModelRequest.php | 67 + AutoMl/src/V1/ImportDataRequest.php | 109 ++ AutoMl/src/V1/InputConfig.php | 134 ++ AutoMl/src/V1/ListDatasetsRequest.php | 205 +++ AutoMl/src/V1/ListDatasetsResponse.php | 105 ++ AutoMl/src/V1/ListModelEvaluationsRequest.php | 217 +++ .../src/V1/ListModelEvaluationsResponse.php | 109 ++ AutoMl/src/V1/ListModelsRequest.php | 205 +++ AutoMl/src/V1/ListModelsResponse.php | 105 ++ AutoMl/src/V1/Model.php | 352 ++++ AutoMl/src/V1/Model/DeploymentState.php | 64 + AutoMl/src/V1/ModelEvaluation.php | 246 +++ AutoMl/src/V1/Model_DeploymentState.php | 16 + AutoMl/src/V1/OperationMetadata.php | 250 +++ AutoMl/src/V1/OutputConfig.php | 98 ++ AutoMl/src/V1/PredictRequest.php | 143 ++ AutoMl/src/V1/PredictResponse.php | 105 ++ AutoMl/src/V1/PredictionServiceClient.php | 38 + AutoMl/src/V1/PredictionServiceGrpcClient.php | 57 + AutoMl/src/V1/TextSnippet.php | 147 ++ AutoMl/src/V1/TranslationAnnotation.php | 67 + AutoMl/src/V1/TranslationDatasetMetadata.php | 101 ++ .../src/V1/TranslationEvaluationMetrics.php | 101 ++ AutoMl/src/V1/TranslationModelMetadata.php | 155 ++ AutoMl/src/V1/UpdateDatasetRequest.php | 101 ++ AutoMl/src/V1/UpdateModelRequest.php | 101 ++ .../V1/resources/auto_ml_client_config.json | 96 ++ .../resources/auto_ml_descriptor_config.php | 88 + .../resources/auto_ml_rest_client_config.php | 267 +++ .../prediction_service_client_config.json | 31 + .../prediction_service_descriptor_config.php | 8 + .../prediction_service_rest_client_config.php | 117 ++ AutoMl/synth.metadata | 24 +- AutoMl/synth.py | 40 +- AutoMl/tests/System/V1/AutoMlSmokeTest.php | 94 + AutoMl/tests/Unit/V1/AutoMlClientTest.php | 1528 +++++++++++++++++ .../Unit/V1/PredictionServiceClientTest.php | 147 ++ README.md | 4 +- docs/contents/cloud-automl.json | 17 + 68 files changed, 9807 insertions(+), 29 deletions(-) create mode 100644 AutoMl/metadata/V1/AnnotationPayload.php create mode 100644 AutoMl/metadata/V1/DataItems.php create mode 100644 AutoMl/metadata/V1/Dataset.php create mode 100644 AutoMl/metadata/V1/Io.php create mode 100644 AutoMl/metadata/V1/Model.php create mode 100644 AutoMl/metadata/V1/ModelEvaluation.php create mode 100644 AutoMl/metadata/V1/Operations.php create mode 100644 AutoMl/metadata/V1/PredictionService.php create mode 100644 AutoMl/metadata/V1/Service.php create mode 100644 AutoMl/metadata/V1/Translation.php create mode 100644 AutoMl/src/V1/AnnotationPayload.php create mode 100644 AutoMl/src/V1/AutoMlClient.php create mode 100644 AutoMl/src/V1/AutoMlGrpcClient.php create mode 100644 AutoMl/src/V1/CreateDatasetRequest.php create mode 100644 AutoMl/src/V1/CreateModelOperationMetadata.php create mode 100644 AutoMl/src/V1/CreateModelRequest.php create mode 100644 AutoMl/src/V1/Dataset.php create mode 100644 AutoMl/src/V1/DeleteDatasetRequest.php create mode 100644 AutoMl/src/V1/DeleteModelRequest.php create mode 100644 AutoMl/src/V1/DeleteOperationMetadata.php create mode 100644 AutoMl/src/V1/ExamplePayload.php create mode 100644 AutoMl/src/V1/ExportDataRequest.php create mode 100644 AutoMl/src/V1/Gapic/AutoMlGapicClient.php create mode 100644 AutoMl/src/V1/Gapic/PredictionServiceGapicClient.php create mode 100644 AutoMl/src/V1/GcsDestination.php create mode 100644 AutoMl/src/V1/GcsSource.php create mode 100644 AutoMl/src/V1/GetDatasetRequest.php create mode 100644 AutoMl/src/V1/GetModelEvaluationRequest.php create mode 100644 AutoMl/src/V1/GetModelRequest.php create mode 100644 AutoMl/src/V1/ImportDataRequest.php create mode 100644 AutoMl/src/V1/InputConfig.php create mode 100644 AutoMl/src/V1/ListDatasetsRequest.php create mode 100644 AutoMl/src/V1/ListDatasetsResponse.php create mode 100644 AutoMl/src/V1/ListModelEvaluationsRequest.php create mode 100644 AutoMl/src/V1/ListModelEvaluationsResponse.php create mode 100644 AutoMl/src/V1/ListModelsRequest.php create mode 100644 AutoMl/src/V1/ListModelsResponse.php create mode 100644 AutoMl/src/V1/Model.php create mode 100644 AutoMl/src/V1/Model/DeploymentState.php create mode 100644 AutoMl/src/V1/ModelEvaluation.php create mode 100644 AutoMl/src/V1/Model_DeploymentState.php create mode 100644 AutoMl/src/V1/OperationMetadata.php create mode 100644 AutoMl/src/V1/OutputConfig.php create mode 100644 AutoMl/src/V1/PredictRequest.php create mode 100644 AutoMl/src/V1/PredictResponse.php create mode 100644 AutoMl/src/V1/PredictionServiceClient.php create mode 100644 AutoMl/src/V1/PredictionServiceGrpcClient.php create mode 100644 AutoMl/src/V1/TextSnippet.php create mode 100644 AutoMl/src/V1/TranslationAnnotation.php create mode 100644 AutoMl/src/V1/TranslationDatasetMetadata.php create mode 100644 AutoMl/src/V1/TranslationEvaluationMetrics.php create mode 100644 AutoMl/src/V1/TranslationModelMetadata.php create mode 100644 AutoMl/src/V1/UpdateDatasetRequest.php create mode 100644 AutoMl/src/V1/UpdateModelRequest.php create mode 100644 AutoMl/src/V1/resources/auto_ml_client_config.json create mode 100644 AutoMl/src/V1/resources/auto_ml_descriptor_config.php create mode 100644 AutoMl/src/V1/resources/auto_ml_rest_client_config.php create mode 100644 AutoMl/src/V1/resources/prediction_service_client_config.json create mode 100644 AutoMl/src/V1/resources/prediction_service_descriptor_config.php create mode 100644 AutoMl/src/V1/resources/prediction_service_rest_client_config.php create mode 100644 AutoMl/tests/System/V1/AutoMlSmokeTest.php create mode 100644 AutoMl/tests/Unit/V1/AutoMlClientTest.php create mode 100644 AutoMl/tests/Unit/V1/PredictionServiceClientTest.php diff --git a/AutoMl/README.md b/AutoMl/README.md index 879426236c38..f7c7578c2b0e 100644 --- a/AutoMl/README.md +++ b/AutoMl/README.md @@ -39,8 +39,8 @@ on authenticating your client. Once authenticated, you'll be ready to start maki ```php require 'vendor/autoload.php'; -use Google\Cloud\AutoMl\V1beta1\AutoMlClient; -use Google\Cloud\AutoMl\V1beta1\TranslationDatasetMetadata; +use Google\Cloud\AutoMl\V1\AutoMlClient; +use Google\Cloud\AutoMl\V1\TranslationDatasetMetadata; $autoMlClient = new AutoMlClient(); $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]'); diff --git a/AutoMl/metadata/V1/AnnotationPayload.php b/AutoMl/metadata/V1/AnnotationPayload.php new file mode 100644 index 000000000000..2a2919720a16 --- /dev/null +++ b/AutoMl/metadata/V1/AnnotationPayload.php @@ -0,0 +1,40 @@ +internalAddGeneratedFile(hex2bin( + "0a9c030a2f676f6f676c652f636c6f75642f6175746f6d6c2f76312f616e" . + "6e6f746174696f6e5f7061796c6f61642e70726f746f1216676f6f676c65" . + "2e636c6f75642e6175746f6d6c2e76311a19676f6f676c652f70726f746f" . + "6275662f616e792e70726f746f1a1c676f6f676c652f6170692f616e6e6f" . + "746174696f6e732e70726f746f22630a11416e6e6f746174696f6e506179" . + "6c6f616412440a0b7472616e736c6174696f6e18022001280b322d2e676f" . + "6f676c652e636c6f75642e6175746f6d6c2e76312e5472616e736c617469" . + "6f6e416e6e6f746174696f6e480042080a0664657461696c42aa010a1a63" . + "6f6d2e676f6f676c652e636c6f75642e6175746f6d6c2e763150015a3c67" . + "6f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f676f6f67" . + "6c65617069732f636c6f75642f6175746f6d6c2f76313b6175746f6d6caa" . + "0216476f6f676c652e436c6f75642e4175746f4d4c2e5631ca0216476f6f" . + "676c655c436c6f75645c4175746f4d6c5c5631ea0219476f6f676c653a3a" . + "436c6f75643a3a4175746f4d4c3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/DataItems.php b/AutoMl/metadata/V1/DataItems.php new file mode 100644 index 000000000000..2fbcd60edf01 --- /dev/null +++ b/AutoMl/metadata/V1/DataItems.php @@ -0,0 +1,46 @@ +internalAddGeneratedFile(hex2bin( + "0a8f040a27676f6f676c652f636c6f75642f6175746f6d6c2f76312f6461" . + "74615f6974656d732e70726f746f1216676f6f676c652e636c6f75642e61" . + "75746f6d6c2e76311a19676f6f676c652f70726f746f6275662f616e792e" . + "70726f746f1a1e676f6f676c652f70726f746f6275662f6475726174696f" . + "6e2e70726f746f1a1c676f6f676c652f70726f746f6275662f7374727563" . + "742e70726f746f1a1c676f6f676c652f6170692f616e6e6f746174696f6e" . + "732e70726f746f22460a0b54657874536e6970706574120f0a07636f6e74" . + "656e7418012001280912110a096d696d655f747970651802200128091213" . + "0a0b636f6e74656e745f75726918042001280922580a0e4578616d706c65" . + "5061796c6f6164123b0a0c746578745f736e697070657418022001280b32" . + "232e676f6f676c652e636c6f75642e6175746f6d6c2e76312e5465787453" . + "6e6970706574480042090a077061796c6f616442aa010a1a636f6d2e676f" . + "6f676c652e636c6f75642e6175746f6d6c2e763150015a3c676f6f676c65" . + "2e676f6c616e672e6f72672f67656e70726f746f2f676f6f676c65617069" . + "732f636c6f75642f6175746f6d6c2f76313b6175746f6d6caa0216476f6f" . + "676c652e436c6f75642e4175746f4d4c2e5631ca0216476f6f676c655c43" . + "6c6f75645c4175746f4d6c5c5631ea0219476f6f676c653a3a436c6f7564" . + "3a3a4175746f4d4c3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/Dataset.php b/AutoMl/metadata/V1/Dataset.php new file mode 100644 index 000000000000..2e2a573a607a --- /dev/null +++ b/AutoMl/metadata/V1/Dataset.php @@ -0,0 +1,49 @@ +internalAddGeneratedFile(hex2bin( + "0aa9050a24676f6f676c652f636c6f75642f6175746f6d6c2f76312f6461" . + "74617365742e70726f746f1216676f6f676c652e636c6f75642e6175746f" . + "6d6c2e76311a1f676f6f676c652f70726f746f6275662f74696d65737461" . + "6d702e70726f746f1a1c676f6f676c652f6170692f616e6e6f746174696f" . + "6e732e70726f746f22f4020a0744617461736574125a0a1c7472616e736c" . + "6174696f6e5f646174617365745f6d6574616461746118172001280b3232" . + "2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e5472616e736c" . + "6174696f6e446174617365744d657461646174614800120c0a046e616d65" . + "18012001280912140a0c646973706c61795f6e616d651802200128091213" . + "0a0b6465736372697074696f6e18032001280912150a0d6578616d706c65" . + "5f636f756e74181520012805122f0a0b6372656174655f74696d65180e20" . + "01280b321a2e676f6f676c652e70726f746f6275662e54696d657374616d" . + "70120c0a0465746167181120012809123b0a066c6162656c731827200328" . + "0b322b2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e446174" . + "617365742e4c6162656c73456e7472791a2d0a0b4c6162656c73456e7472" . + "79120b0a036b6579180120012809120d0a0576616c75651802200128093a" . + "02380142120a10646174617365745f6d6574616461746142aa010a1a636f" . + "6d2e676f6f676c652e636c6f75642e6175746f6d6c2e763150015a3c676f" . + "6f676c652e676f6c616e672e6f72672f67656e70726f746f2f676f6f676c" . + "65617069732f636c6f75642f6175746f6d6c2f76313b6175746f6d6caa02" . + "16476f6f676c652e436c6f75642e4175746f4d4c2e5631ca0216476f6f67" . + "6c655c436c6f75645c4175746f4d6c5c5631ea0219476f6f676c653a3a43" . + "6c6f75643a3a4175746f4d4c3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/Io.php b/AutoMl/metadata/V1/Io.php new file mode 100644 index 000000000000..388a58f370da --- /dev/null +++ b/AutoMl/metadata/V1/Io.php @@ -0,0 +1,45 @@ +internalAddGeneratedFile(hex2bin( + "0ae1040a1f676f6f676c652f636c6f75642f6175746f6d6c2f76312f696f" . + "2e70726f746f1216676f6f676c652e636c6f75642e6175746f6d6c2e7631" . + "22c0010a0b496e707574436f6e66696712370a0a6763735f736f75726365" . + "18012001280b32212e676f6f676c652e636c6f75642e6175746f6d6c2e76" . + "312e476373536f757263654800123f0a06706172616d7318022003280b32" . + "2f2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e496e707574" . + "436f6e6669672e506172616d73456e7472791a2d0a0b506172616d73456e" . + "747279120b0a036b6579180120012809120d0a0576616c75651802200128" . + "093a02380142080a06736f7572636522600a0c4f7574707574436f6e6669" . + "6712410a0f6763735f64657374696e6174696f6e18012001280b32262e67" . + "6f6f676c652e636c6f75642e6175746f6d6c2e76312e4763734465737469" . + "6e6174696f6e4800420d0a0b64657374696e6174696f6e221f0a09476373" . + "536f7572636512120a0a696e7075745f75726973180120032809222b0a0e" . + "47637344657374696e6174696f6e12190a116f75747075745f7572695f70" . + "726566697818012001280942aa010a1a636f6d2e676f6f676c652e636c6f" . + "75642e6175746f6d6c2e763150015a3c676f6f676c652e676f6c616e672e" . + "6f72672f67656e70726f746f2f676f6f676c65617069732f636c6f75642f" . + "6175746f6d6c2f76313b6175746f6d6caa0216476f6f676c652e436c6f75" . + "642e4175746f4d4c2e5631ca0216476f6f676c655c436c6f75645c417574" . + "6f4d6c5c5631ea0219476f6f676c653a3a436c6f75643a3a4175746f4d4c" . + "3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/Model.php b/AutoMl/metadata/V1/Model.php new file mode 100644 index 000000000000..afb80aea20b9 --- /dev/null +++ b/AutoMl/metadata/V1/Model.php @@ -0,0 +1,54 @@ +internalAddGeneratedFile(hex2bin( + "0ac4060a22676f6f676c652f636c6f75642f6175746f6d6c2f76312f6d6f" . + "64656c2e70726f746f1216676f6f676c652e636c6f75642e6175746f6d6c" . + "2e76311a1f676f6f676c652f70726f746f6275662f74696d657374616d70" . + "2e70726f746f1a1c676f6f676c652f6170692f616e6e6f746174696f6e73" . + "2e70726f746f2291040a054d6f64656c12560a1a7472616e736c6174696f" . + "6e5f6d6f64656c5f6d65746164617461180f2001280b32302e676f6f676c" . + "652e636c6f75642e6175746f6d6c2e76312e5472616e736c6174696f6e4d" . + "6f64656c4d657461646174614800120c0a046e616d651801200128091214" . + "0a0c646973706c61795f6e616d6518022001280912120a0a646174617365" . + "745f6964180320012809122f0a0b6372656174655f74696d651807200128" . + "0b321a2e676f6f676c652e70726f746f6275662e54696d657374616d7012" . + "2f0a0b7570646174655f74696d65180b2001280b321a2e676f6f676c652e" . + "70726f746f6275662e54696d657374616d7012470a106465706c6f796d65" . + "6e745f737461746518082001280e322d2e676f6f676c652e636c6f75642e" . + "6175746f6d6c2e76312e4d6f64656c2e4465706c6f796d656e7453746174" . + "6512390a066c6162656c7318222003280b32292e676f6f676c652e636c6f" . + "75642e6175746f6d6c2e76312e4d6f64656c2e4c6162656c73456e747279" . + "1a2d0a0b4c6162656c73456e747279120b0a036b6579180120012809120d" . + "0a0576616c75651802200128093a02380122510a0f4465706c6f796d656e" . + "74537461746512200a1c4445504c4f594d454e545f53544154455f554e53" . + "50454349464945441000120c0a084445504c4f5945441001120e0a0a554e" . + "4445504c4f594544100242100a0e6d6f64656c5f6d6574616461746142aa" . + "010a1a636f6d2e676f6f676c652e636c6f75642e6175746f6d6c2e763150" . + "015a3c676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f" . + "676f6f676c65617069732f636c6f75642f6175746f6d6c2f76313b617574" . + "6f6d6caa0216476f6f676c652e436c6f75642e4175746f4d4c2e5631ca02" . + "16476f6f676c655c436c6f75645c4175746f4d6c5c5631ea0219476f6f67" . + "6c653a3a436c6f75643a3a4175746f4d4c3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/ModelEvaluation.php b/AutoMl/metadata/V1/ModelEvaluation.php new file mode 100644 index 000000000000..110277a22bdf --- /dev/null +++ b/AutoMl/metadata/V1/ModelEvaluation.php @@ -0,0 +1,45 @@ +internalAddGeneratedFile(hex2bin( + "0ab6040a2d676f6f676c652f636c6f75642f6175746f6d6c2f76312f6d6f" . + "64656c5f6576616c756174696f6e2e70726f746f1216676f6f676c652e63" . + "6c6f75642e6175746f6d6c2e76311a1f676f6f676c652f70726f746f6275" . + "662f74696d657374616d702e70726f746f1a1c676f6f676c652f6170692f" . + "616e6e6f746174696f6e732e70726f746f22f8010a0f4d6f64656c457661" . + "6c756174696f6e125e0a1e7472616e736c6174696f6e5f6576616c756174" . + "696f6e5f6d65747269637318092001280b32342e676f6f676c652e636c6f" . + "75642e6175746f6d6c2e76312e5472616e736c6174696f6e4576616c7561" . + "74696f6e4d6574726963734800120c0a046e616d65180120012809121a0a" . + "12616e6e6f746174696f6e5f737065635f6964180220012809122f0a0b63" . + "72656174655f74696d6518052001280b321a2e676f6f676c652e70726f74" . + "6f6275662e54696d657374616d70121f0a176576616c75617465645f6578" . + "616d706c655f636f756e7418062001280542090a076d65747269637342aa" . + "010a1a636f6d2e676f6f676c652e636c6f75642e6175746f6d6c2e763150" . + "015a3c676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f" . + "676f6f676c65617069732f636c6f75642f6175746f6d6c2f76313b617574" . + "6f6d6caa0216476f6f676c652e436c6f75642e4175746f4d4c2e5631ca02" . + "16476f6f676c655c436c6f75645c4175746f4d6c5c5631ea0219476f6f67" . + "6c653a3a436c6f75643a3a4175746f4d4c3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/Operations.php b/AutoMl/metadata/V1/Operations.php new file mode 100644 index 000000000000..02983c81b2a5 --- /dev/null +++ b/AutoMl/metadata/V1/Operations.php @@ -0,0 +1,64 @@ +internalAddGeneratedFile(hex2bin( + "0abc070a27676f6f676c652f636c6f75642f6175746f6d6c2f76312f6f70" . + "65726174696f6e732e70726f746f1216676f6f676c652e636c6f75642e61" . + "75746f6d6c2e76311a22676f6f676c652f636c6f75642f6175746f6d6c2f" . + "76312f6d6f64656c2e70726f746f1a2d676f6f676c652f636c6f75642f61" . + "75746f6d6c2f76312f6d6f64656c5f6576616c756174696f6e2e70726f74" . + "6f1a2f676f6f676c652f636c6f75642f6175746f6d6c2f76312f70726564" . + "696374696f6e5f736572766963652e70726f746f1a24676f6f676c652f63" . + "6c6f75642f6175746f6d6c2f76312f736572766963652e70726f746f1a1b" . + "676f6f676c652f70726f746f6275662f656d7074792e70726f746f1a1f67" . + "6f6f676c652f70726f746f6275662f74696d657374616d702e70726f746f" . + "1a17676f6f676c652f7270632f7374617475732e70726f746f1a1c676f6f" . + "676c652f6170692f616e6e6f746174696f6e732e70726f746f22e9020a11" . + "4f7065726174696f6e4d6574616461746112490a0e64656c6574655f6465" . + "7461696c7318082001280b322f2e676f6f676c652e636c6f75642e617574" . + "6f6d6c2e76312e44656c6574654f7065726174696f6e4d65746164617461" . + "480012540a146372656174655f6d6f64656c5f64657461696c73180a2001" . + "280b32342e676f6f676c652e636c6f75642e6175746f6d6c2e76312e4372" . + "656174654d6f64656c4f7065726174696f6e4d6574616461746148001218" . + "0a1070726f67726573735f70657263656e74180d20012805122c0a107061" . + "727469616c5f6661696c7572657318022003280b32122e676f6f676c652e" . + "7270632e537461747573122f0a0b6372656174655f74696d651803200128" . + "0b321a2e676f6f676c652e70726f746f6275662e54696d657374616d7012" . + "2f0a0b7570646174655f74696d6518042001280b321a2e676f6f676c652e" . + "70726f746f6275662e54696d657374616d7042090a0764657461696c7322" . + "190a1744656c6574654f7065726174696f6e4d65746164617461221e0a1c" . + "4372656174654d6f64656c4f7065726174696f6e4d6574616461746142aa" . + "010a1a636f6d2e676f6f676c652e636c6f75642e6175746f6d6c2e763150" . + "015a3c676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f" . + "676f6f676c65617069732f636c6f75642f6175746f6d6c2f76313b617574" . + "6f6d6caa0216476f6f676c652e436c6f75642e4175746f4d4c2e5631ca02" . + "16476f6f676c655c436c6f75645c4175746f4d6c5c5631ea0219476f6f67" . + "6c653a3a436c6f75643a3a4175746f4d4c3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/PredictionService.php b/AutoMl/metadata/V1/PredictionService.php new file mode 100644 index 000000000000..ea7515e9da1d --- /dev/null +++ b/AutoMl/metadata/V1/PredictionService.php @@ -0,0 +1,67 @@ +internalAddGeneratedFile(hex2bin( + "0ae3080a2f676f6f676c652f636c6f75642f6175746f6d6c2f76312f7072" . + "6564696374696f6e5f736572766963652e70726f746f1216676f6f676c65" . + "2e636c6f75642e6175746f6d6c2e76311a2f676f6f676c652f636c6f7564" . + "2f6175746f6d6c2f76312f616e6e6f746174696f6e5f7061796c6f61642e" . + "70726f746f1a27676f6f676c652f636c6f75642f6175746f6d6c2f76312f" . + "646174615f6974656d732e70726f746f1a1f676f6f676c652f636c6f7564" . + "2f6175746f6d6c2f76312f696f2e70726f746f1a23676f6f676c652f6c6f" . + "6e6772756e6e696e672f6f7065726174696f6e732e70726f746f1a17676f" . + "6f676c652f6170692f636c69656e742e70726f746f22ca010a0e50726564" . + "69637452657175657374120c0a046e616d6518012001280912370a077061" . + "796c6f616418022001280b32262e676f6f676c652e636c6f75642e617574" . + "6f6d6c2e76312e4578616d706c655061796c6f616412420a06706172616d" . + "7318032003280b32322e676f6f676c652e636c6f75642e6175746f6d6c2e" . + "76312e50726564696374526571756573742e506172616d73456e7472791a" . + "2d0a0b506172616d73456e747279120b0a036b6579180120012809120d0a" . + "0576616c75651802200128093a02380122c7010a0f507265646963745265" . + "73706f6e7365123a0a077061796c6f616418012003280b32292e676f6f67" . + "6c652e636c6f75642e6175746f6d6c2e76312e416e6e6f746174696f6e50" . + "61796c6f616412470a086d6574616461746118022003280b32352e676f6f" . + "676c652e636c6f75642e6175746f6d6c2e76312e50726564696374526573" . + "706f6e73652e4d65746164617461456e7472791a2f0a0d4d657461646174" . + "61456e747279120b0a036b6579180120012809120d0a0576616c75651802" . + "200128093a02380132fa010a1150726564696374696f6e53657276696365" . + "1299010a075072656469637412262e676f6f676c652e636c6f75642e6175" . + "746f6d6c2e76312e50726564696374526571756573741a272e676f6f676c" . + "652e636c6f75642e6175746f6d6c2e76312e50726564696374526573706f" . + "6e7365223d82d3e493023722322f76312f7b6e616d653d70726f6a656374" . + "732f2a2f6c6f636174696f6e732f2a2f6d6f64656c732f2a7d3a70726564" . + "6963743a012a1a49ca41156175746f6d6c2e676f6f676c65617069732e63" . + "6f6dd2412e68747470733a2f2f7777772e676f6f676c65617069732e636f" . + "6d2f617574682f636c6f75642d706c6174666f726d42c2010a1a636f6d2e" . + "676f6f676c652e636c6f75642e6175746f6d6c2e76314216507265646963" . + "74696f6e5365727669636550726f746f50015a3c676f6f676c652e676f6c" . + "616e672e6f72672f67656e70726f746f2f676f6f676c65617069732f636c" . + "6f75642f6175746f6d6c2f76313b6175746f6d6caa0216476f6f676c652e" . + "436c6f75642e4175746f4d4c2e5631ca0216476f6f676c655c436c6f7564" . + "5c4175746f4d6c5c5631ea0219476f6f676c653a3a436c6f75643a3a4175" . + "746f4d4c3a3a5631620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/Service.php b/AutoMl/metadata/V1/Service.php new file mode 100644 index 000000000000..9755c2d7a365 --- /dev/null +++ b/AutoMl/metadata/V1/Service.php @@ -0,0 +1,175 @@ +internalAddGeneratedFile(hex2bin( + "0aa4210a24676f6f676c652f636c6f75642f6175746f6d6c2f76312f7365" . + "72766963652e70726f746f1216676f6f676c652e636c6f75642e6175746f" . + "6d6c2e76311a2f676f6f676c652f636c6f75642f6175746f6d6c2f76312f" . + "616e6e6f746174696f6e5f7061796c6f61642e70726f746f1a24676f6f67" . + "6c652f636c6f75642f6175746f6d6c2f76312f646174617365742e70726f" . + "746f1a1f676f6f676c652f636c6f75642f6175746f6d6c2f76312f696f2e" . + "70726f746f1a22676f6f676c652f636c6f75642f6175746f6d6c2f76312f" . + "6d6f64656c2e70726f746f1a2d676f6f676c652f636c6f75642f6175746f" . + "6d6c2f76312f6d6f64656c5f6576616c756174696f6e2e70726f746f1a23" . + "676f6f676c652f6c6f6e6772756e6e696e672f6f7065726174696f6e732e" . + "70726f746f1a20676f6f676c652f70726f746f6275662f6669656c645f6d" . + "61736b2e70726f746f1a17676f6f676c652f6170692f636c69656e742e70" . + "726f746f22580a144372656174654461746173657452657175657374120e" . + "0a06706172656e7418012001280912300a07646174617365741802200128" . + "0b321f2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e446174" . + "6173657422210a114765744461746173657452657175657374120c0a046e" . + "616d65180120012809225c0a134c69737444617461736574735265717565" . + "7374120e0a06706172656e74180120012809120e0a0666696c7465721803" . + "2001280912110a09706167655f73697a6518042001280512120a0a706167" . + "655f746f6b656e18062001280922620a144c697374446174617365747352" . + "6573706f6e736512310a08646174617365747318012003280b321f2e676f" . + "6f676c652e636c6f75642e6175746f6d6c2e76312e446174617365741217" . + "0a0f6e6578745f706167655f746f6b656e18022001280922790a14557064" . + "617465446174617365745265717565737412300a07646174617365741801" . + "2001280b321f2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e" . + "44617461736574122f0a0b7570646174655f6d61736b18022001280b321a" . + "2e676f6f676c652e70726f746f6275662e4669656c644d61736b22240a14" . + "44656c6574654461746173657452657175657374120c0a046e616d651801" . + "20012809225c0a11496d706f72744461746152657175657374120c0a046e" . + "616d6518012001280912390a0c696e7075745f636f6e6669671803200128" . + "0b32232e676f6f676c652e636c6f75642e6175746f6d6c2e76312e496e70" . + "7574436f6e666967225e0a114578706f7274446174615265717565737412" . + "0c0a046e616d65180120012809123b0a0d6f75747075745f636f6e666967" . + "18032001280b32242e676f6f676c652e636c6f75642e6175746f6d6c2e76" . + "312e4f7574707574436f6e66696722520a124372656174654d6f64656c52" . + "657175657374120e0a06706172656e74180120012809122c0a056d6f6465" . + "6c18042001280b321d2e676f6f676c652e636c6f75642e6175746f6d6c2e" . + "76312e4d6f64656c221f0a0f4765744d6f64656c52657175657374120c0a" . + "046e616d65180120012809225a0a114c6973744d6f64656c735265717565" . + "7374120e0a06706172656e74180120012809120e0a0666696c7465721803" . + "2001280912110a09706167655f73697a6518042001280512120a0a706167" . + "655f746f6b656e180620012809225b0a124c6973744d6f64656c73526573" . + "706f6e7365122c0a056d6f64656c18012003280b321d2e676f6f676c652e" . + "636c6f75642e6175746f6d6c2e76312e4d6f64656c12170a0f6e6578745f" . + "706167655f746f6b656e18022001280922220a1244656c6574654d6f6465" . + "6c52657175657374120c0a046e616d6518012001280922730a1255706461" . + "74654d6f64656c52657175657374122c0a056d6f64656c18012001280b32" . + "1d2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e4d6f64656c" . + "122f0a0b7570646174655f6d61736b18022001280b321a2e676f6f676c65" . + "2e70726f746f6275662e4669656c644d61736b22290a194765744d6f6465" . + "6c4576616c756174696f6e52657175657374120c0a046e616d6518012001" . + "280922640a1b4c6973744d6f64656c4576616c756174696f6e7352657175" . + "657374120e0a06706172656e74180120012809120e0a0666696c74657218" . + "032001280912110a09706167655f73697a6518042001280512120a0a7061" . + "67655f746f6b656e180620012809227a0a1c4c6973744d6f64656c457661" . + "6c756174696f6e73526573706f6e736512410a106d6f64656c5f6576616c" . + "756174696f6e18012003280b32272e676f6f676c652e636c6f75642e6175" . + "746f6d6c2e76312e4d6f64656c4576616c756174696f6e12170a0f6e6578" . + "745f706167655f746f6b656e1802200128093284120a064175746f4d6c12" . + "9b010a0d43726561746544617461736574122c2e676f6f676c652e636c6f" . + "75642e6175746f6d6c2e76312e4372656174654461746173657452657175" . + "6573741a1d2e676f6f676c652e6c6f6e6772756e6e696e672e4f70657261" . + "74696f6e223d82d3e4930237222c2f76312f7b706172656e743d70726f6a" . + "656374732f2a2f6c6f636174696f6e732f2a7d2f64617461736574733a07" . + "64617461736574128e010a0a4765744461746173657412292e676f6f676c" . + "652e636c6f75642e6175746f6d6c2e76312e476574446174617365745265" . + "71756573741a1f2e676f6f676c652e636c6f75642e6175746f6d6c2e7631" . + "2e44617461736574223482d3e493022e122c2f76312f7b6e616d653d7072" . + "6f6a656374732f2a2f6c6f636174696f6e732f2a2f64617461736574732f" . + "2a7d129f010a0c4c6973744461746173657473122b2e676f6f676c652e63" . + "6c6f75642e6175746f6d6c2e76312e4c6973744461746173657473526571" . + "756573741a2c2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e" . + "4c6973744461746173657473526573706f6e7365223482d3e493022e122c" . + "2f76312f7b706172656e743d70726f6a656374732f2a2f6c6f636174696f" . + "6e732f2a7d2f646174617365747312a5010a0d5570646174654461746173" . + "6574122c2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e5570" . + "6461746544617461736574526571756573741a1f2e676f6f676c652e636c" . + "6f75642e6175746f6d6c2e76312e44617461736574224582d3e493023f32" . + "342f76312f7b646174617365742e6e616d653d70726f6a656374732f2a2f" . + "6c6f636174696f6e732f2a2f64617461736574732f2a7d3a076461746173" . + "65741292010a0d44656c65746544617461736574122c2e676f6f676c652e" . + "636c6f75642e6175746f6d6c2e76312e44656c6574654461746173657452" . + "6571756573741a1d2e676f6f676c652e6c6f6e6772756e6e696e672e4f70" . + "65726174696f6e223482d3e493022e2a2c2f76312f7b6e616d653d70726f" . + "6a656374732f2a2f6c6f636174696f6e732f2a2f64617461736574732f2a" . + "7d129a010a0a496d706f72744461746112292e676f6f676c652e636c6f75" . + "642e6175746f6d6c2e76312e496d706f727444617461526571756573741a" . + "1d2e676f6f676c652e6c6f6e6772756e6e696e672e4f7065726174696f6e" . + "224282d3e493023c22372f76312f7b6e616d653d70726f6a656374732f2a" . + "2f6c6f636174696f6e732f2a2f64617461736574732f2a7d3a696d706f72" . + "74446174613a012a129a010a0a4578706f72744461746112292e676f6f67" . + "6c652e636c6f75642e6175746f6d6c2e76312e4578706f72744461746152" . + "6571756573741a1d2e676f6f676c652e6c6f6e6772756e6e696e672e4f70" . + "65726174696f6e224282d3e493023c22372f76312f7b6e616d653d70726f" . + "6a656374732f2a2f6c6f636174696f6e732f2a2f64617461736574732f2a" . + "7d3a6578706f7274446174613a012a1293010a0b4372656174654d6f6465" . + "6c122a2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e437265" . + "6174654d6f64656c526571756573741a1d2e676f6f676c652e6c6f6e6772" . + "756e6e696e672e4f7065726174696f6e223982d3e4930233222a2f76312f" . + "7b706172656e743d70726f6a656374732f2a2f6c6f636174696f6e732f2a" . + "7d2f6d6f64656c733a056d6f64656c1286010a084765744d6f64656c1227" . + "2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e4765744d6f64" . + "656c526571756573741a1d2e676f6f676c652e636c6f75642e6175746f6d" . + "6c2e76312e4d6f64656c223282d3e493022c122a2f76312f7b6e616d653d" . + "70726f6a656374732f2a2f6c6f636174696f6e732f2a2f6d6f64656c732f" . + "2a7d1297010a0a4c6973744d6f64656c7312292e676f6f676c652e636c6f" . + "75642e6175746f6d6c2e76312e4c6973744d6f64656c7352657175657374" . + "1a2a2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e4c697374" . + "4d6f64656c73526573706f6e7365223282d3e493022c122a2f76312f7b70" . + "6172656e743d70726f6a656374732f2a2f6c6f636174696f6e732f2a7d2f" . + "6d6f64656c73128c010a0b44656c6574654d6f64656c122a2e676f6f676c" . + "652e636c6f75642e6175746f6d6c2e76312e44656c6574654d6f64656c52" . + "6571756573741a1d2e676f6f676c652e6c6f6e6772756e6e696e672e4f70" . + "65726174696f6e223282d3e493022c2a2a2f76312f7b6e616d653d70726f" . + "6a656374732f2a2f6c6f636174696f6e732f2a2f6d6f64656c732f2a7d12" . + "99010a0b5570646174654d6f64656c122a2e676f6f676c652e636c6f7564" . + "2e6175746f6d6c2e76312e5570646174654d6f64656c526571756573741a" . + "1d2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e4d6f64656c" . + "223f82d3e493023932302f76312f7b6d6f64656c2e6e616d653d70726f6a" . + "656374732f2a2f6c6f636174696f6e732f2a2f6d6f64656c732f2a7d3a05" . + "6d6f64656c12b7010a124765744d6f64656c4576616c756174696f6e1231" . + "2e676f6f676c652e636c6f75642e6175746f6d6c2e76312e4765744d6f64" . + "656c4576616c756174696f6e526571756573741a272e676f6f676c652e63" . + "6c6f75642e6175746f6d6c2e76312e4d6f64656c4576616c756174696f6e" . + "224582d3e493023f123d2f76312f7b6e616d653d70726f6a656374732f2a" . + "2f6c6f636174696f6e732f2a2f6d6f64656c732f2a2f6d6f64656c457661" . + "6c756174696f6e732f2a7d12c8010a144c6973744d6f64656c4576616c75" . + "6174696f6e7312332e676f6f676c652e636c6f75642e6175746f6d6c2e76" . + "312e4c6973744d6f64656c4576616c756174696f6e73526571756573741a" . + "342e676f6f676c652e636c6f75642e6175746f6d6c2e76312e4c6973744d" . + "6f64656c4576616c756174696f6e73526573706f6e7365224582d3e49302" . + "3f123d2f76312f7b706172656e743d70726f6a656374732f2a2f6c6f6361" . + "74696f6e732f2a2f6d6f64656c732f2a7d2f6d6f64656c4576616c756174" . + "696f6e731a49ca41156175746f6d6c2e676f6f676c65617069732e636f6d" . + "d2412e68747470733a2f2f7777772e676f6f676c65617069732e636f6d2f" . + "617574682f636c6f75642d706c6174666f726d42b7010a1a636f6d2e676f" . + "6f676c652e636c6f75642e6175746f6d6c2e7631420b4175746f4d6c5072" . + "6f746f50015a3c676f6f676c652e676f6c616e672e6f72672f67656e7072" . + "6f746f2f676f6f676c65617069732f636c6f75642f6175746f6d6c2f7631" . + "3b6175746f6d6caa0216476f6f676c652e436c6f75642e4175746f4d4c2e" . + "5631ca0216476f6f676c655c436c6f75645c4175746f4d6c5c5631ea0219" . + "476f6f676c653a3a436c6f75643a3a4175746f4d4c3a3a5631620670726f" . + "746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/metadata/V1/Translation.php b/AutoMl/metadata/V1/Translation.php new file mode 100644 index 000000000000..85996249223b --- /dev/null +++ b/AutoMl/metadata/V1/Translation.php @@ -0,0 +1,48 @@ +internalAddGeneratedFile(hex2bin( + "0a94050a28676f6f676c652f636c6f75642f6175746f6d6c2f76312f7472" . + "616e736c6174696f6e2e70726f746f1216676f6f676c652e636c6f75642e" . + "6175746f6d6c2e76311a1c676f6f676c652f6170692f616e6e6f74617469" . + "6f6e732e70726f746f22580a1a5472616e736c6174696f6e446174617365" . + "744d65746164617461121c0a14736f757263655f6c616e67756167655f63" . + "6f6465180120012809121c0a147461726765745f6c616e67756167655f63" . + "6f6465180220012809224b0a1c5472616e736c6174696f6e4576616c7561" . + "74696f6e4d65747269637312120a0a626c65755f73636f72651801200128" . + "0112170a0f626173655f626c65755f73636f7265180220012801226a0a18" . + "5472616e736c6174696f6e4d6f64656c4d6574616461746112120a0a6261" . + "73655f6d6f64656c180120012809121c0a14736f757263655f6c616e6775" . + "6167655f636f6465180220012809121c0a147461726765745f6c616e6775" . + "6167655f636f646518032001280922580a155472616e736c6174696f6e41" . + "6e6e6f746174696f6e123f0a127472616e736c617465645f636f6e74656e" . + "7418012001280b32232e676f6f676c652e636c6f75642e6175746f6d6c2e" . + "76312e54657874536e697070657442bc010a1a636f6d2e676f6f676c652e" . + "636c6f75642e6175746f6d6c2e763142105472616e736c6174696f6e5072" . + "6f746f50015a3c676f6f676c652e676f6c616e672e6f72672f67656e7072" . + "6f746f2f676f6f676c65617069732f636c6f75642f6175746f6d6c2f7631" . + "3b6175746f6d6caa0216476f6f676c652e436c6f75642e4175746f4d4c2e" . + "5631ca0216476f6f676c655c436c6f75645c4175746f4d6c5c5631ea0219" . + "476f6f676c653a3a436c6f75643a3a4175746f4d4c3a3a5631620670726f" . + "746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/AutoMl/src/V1/AnnotationPayload.php b/AutoMl/src/V1/AnnotationPayload.php new file mode 100644 index 000000000000..b5bbe0bf9164 --- /dev/null +++ b/AutoMl/src/V1/AnnotationPayload.php @@ -0,0 +1,70 @@ +google.cloud.automl.v1.AnnotationPayload + */ +class AnnotationPayload extends \Google\Protobuf\Internal\Message +{ + protected $detail; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\TranslationAnnotation $translation + * Annotation details for translation. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\AnnotationPayload::initOnce(); + parent::__construct($data); + } + + /** + * Annotation details for translation. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationAnnotation translation = 2; + * @return \Google\Cloud\AutoMl\V1\TranslationAnnotation + */ + public function getTranslation() + { + return $this->readOneof(2); + } + + /** + * Annotation details for translation. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationAnnotation translation = 2; + * @param \Google\Cloud\AutoMl\V1\TranslationAnnotation $var + * @return $this + */ + public function setTranslation($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\TranslationAnnotation::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * @return string + */ + public function getDetail() + { + return $this->whichOneof("detail"); + } + +} + diff --git a/AutoMl/src/V1/AutoMlClient.php b/AutoMl/src/V1/AutoMlClient.php new file mode 100644 index 000000000000..f8c35f5c1bbe --- /dev/null +++ b/AutoMl/src/V1/AutoMlClient.php @@ -0,0 +1,38 @@ +_simpleRequest('/google.cloud.automl.v1.AutoMl/CreateDataset', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + + /** + * Gets a dataset. + * @param \Google\Cloud\AutoMl\V1\GetDatasetRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function GetDataset(\Google\Cloud\AutoMl\V1\GetDatasetRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/GetDataset', + $argument, + ['\Google\Cloud\AutoMl\V1\Dataset', 'decode'], + $metadata, $options); + } + + /** + * Lists datasets in a project. + * @param \Google\Cloud\AutoMl\V1\ListDatasetsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function ListDatasets(\Google\Cloud\AutoMl\V1\ListDatasetsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/ListDatasets', + $argument, + ['\Google\Cloud\AutoMl\V1\ListDatasetsResponse', 'decode'], + $metadata, $options); + } + + /** + * Updates a dataset. + * @param \Google\Cloud\AutoMl\V1\UpdateDatasetRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function UpdateDataset(\Google\Cloud\AutoMl\V1\UpdateDatasetRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/UpdateDataset', + $argument, + ['\Google\Cloud\AutoMl\V1\Dataset', 'decode'], + $metadata, $options); + } + + /** + * Deletes a dataset and all of its contents. + * Returns empty response in the + * [response][google.longrunning.Operation.response] field when it completes, + * and `delete_details` in the + * [metadata][google.longrunning.Operation.metadata] field. + * @param \Google\Cloud\AutoMl\V1\DeleteDatasetRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function DeleteDataset(\Google\Cloud\AutoMl\V1\DeleteDatasetRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/DeleteDataset', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + + /** + * Imports data into a dataset. + * @param \Google\Cloud\AutoMl\V1\ImportDataRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function ImportData(\Google\Cloud\AutoMl\V1\ImportDataRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/ImportData', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + + /** + * Exports dataset's data to the provided output location. + * Returns an empty response in the + * [response][google.longrunning.Operation.response] field when it completes. + * @param \Google\Cloud\AutoMl\V1\ExportDataRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function ExportData(\Google\Cloud\AutoMl\V1\ExportDataRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/ExportData', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + + /** + * Creates a model. + * Returns a Model in the [response][google.longrunning.Operation.response] + * field when it completes. + * When you create a model, several model evaluations are created for it: + * a global evaluation, and one evaluation for each annotation spec. + * @param \Google\Cloud\AutoMl\V1\CreateModelRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function CreateModel(\Google\Cloud\AutoMl\V1\CreateModelRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/CreateModel', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + + /** + * Gets a model. + * @param \Google\Cloud\AutoMl\V1\GetModelRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function GetModel(\Google\Cloud\AutoMl\V1\GetModelRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/GetModel', + $argument, + ['\Google\Cloud\AutoMl\V1\Model', 'decode'], + $metadata, $options); + } + + /** + * Lists models. + * @param \Google\Cloud\AutoMl\V1\ListModelsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function ListModels(\Google\Cloud\AutoMl\V1\ListModelsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/ListModels', + $argument, + ['\Google\Cloud\AutoMl\V1\ListModelsResponse', 'decode'], + $metadata, $options); + } + + /** + * Deletes a model. + * Returns `google.protobuf.Empty` in the + * [response][google.longrunning.Operation.response] field when it completes, + * and `delete_details` in the + * [metadata][google.longrunning.Operation.metadata] field. + * @param \Google\Cloud\AutoMl\V1\DeleteModelRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function DeleteModel(\Google\Cloud\AutoMl\V1\DeleteModelRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/DeleteModel', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + + /** + * Updates a model. + * @param \Google\Cloud\AutoMl\V1\UpdateModelRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function UpdateModel(\Google\Cloud\AutoMl\V1\UpdateModelRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/UpdateModel', + $argument, + ['\Google\Cloud\AutoMl\V1\Model', 'decode'], + $metadata, $options); + } + + /** + * Gets a model evaluation. + * @param \Google\Cloud\AutoMl\V1\GetModelEvaluationRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function GetModelEvaluation(\Google\Cloud\AutoMl\V1\GetModelEvaluationRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/GetModelEvaluation', + $argument, + ['\Google\Cloud\AutoMl\V1\ModelEvaluation', 'decode'], + $metadata, $options); + } + + /** + * Lists model evaluations. + * @param \Google\Cloud\AutoMl\V1\ListModelEvaluationsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function ListModelEvaluations(\Google\Cloud\AutoMl\V1\ListModelEvaluationsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.automl.v1.AutoMl/ListModelEvaluations', + $argument, + ['\Google\Cloud\AutoMl\V1\ListModelEvaluationsResponse', 'decode'], + $metadata, $options); + } + +} diff --git a/AutoMl/src/V1/CreateDatasetRequest.php b/AutoMl/src/V1/CreateDatasetRequest.php new file mode 100644 index 000000000000..326b9634d245 --- /dev/null +++ b/AutoMl/src/V1/CreateDatasetRequest.php @@ -0,0 +1,101 @@ +google.cloud.automl.v1.CreateDatasetRequest + */ +class CreateDatasetRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the project to create the dataset for. + * + * Generated from protobuf field string parent = 1; + */ + private $parent = ''; + /** + * The dataset to create. + * + * Generated from protobuf field .google.cloud.automl.v1.Dataset dataset = 2; + */ + private $dataset = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * The resource name of the project to create the dataset for. + * @type \Google\Cloud\AutoMl\V1\Dataset $dataset + * The dataset to create. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the project to create the dataset for. + * + * Generated from protobuf field string parent = 1; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * The resource name of the project to create the dataset for. + * + * Generated from protobuf field string parent = 1; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * The dataset to create. + * + * Generated from protobuf field .google.cloud.automl.v1.Dataset dataset = 2; + * @return \Google\Cloud\AutoMl\V1\Dataset + */ + public function getDataset() + { + return $this->dataset; + } + + /** + * The dataset to create. + * + * Generated from protobuf field .google.cloud.automl.v1.Dataset dataset = 2; + * @param \Google\Cloud\AutoMl\V1\Dataset $var + * @return $this + */ + public function setDataset($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\Dataset::class); + $this->dataset = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/CreateModelOperationMetadata.php b/AutoMl/src/V1/CreateModelOperationMetadata.php new file mode 100644 index 000000000000..d02e428ca252 --- /dev/null +++ b/AutoMl/src/V1/CreateModelOperationMetadata.php @@ -0,0 +1,33 @@ +google.cloud.automl.v1.CreateModelOperationMetadata + */ +class CreateModelOperationMetadata extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Operations::initOnce(); + parent::__construct($data); + } + +} + diff --git a/AutoMl/src/V1/CreateModelRequest.php b/AutoMl/src/V1/CreateModelRequest.php new file mode 100644 index 000000000000..e3955bd50279 --- /dev/null +++ b/AutoMl/src/V1/CreateModelRequest.php @@ -0,0 +1,101 @@ +google.cloud.automl.v1.CreateModelRequest + */ +class CreateModelRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of the parent project where the model is being created. + * + * Generated from protobuf field string parent = 1; + */ + private $parent = ''; + /** + * The model to create. + * + * Generated from protobuf field .google.cloud.automl.v1.Model model = 4; + */ + private $model = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Resource name of the parent project where the model is being created. + * @type \Google\Cloud\AutoMl\V1\Model $model + * The model to create. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of the parent project where the model is being created. + * + * Generated from protobuf field string parent = 1; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Resource name of the parent project where the model is being created. + * + * Generated from protobuf field string parent = 1; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * The model to create. + * + * Generated from protobuf field .google.cloud.automl.v1.Model model = 4; + * @return \Google\Cloud\AutoMl\V1\Model + */ + public function getModel() + { + return $this->model; + } + + /** + * The model to create. + * + * Generated from protobuf field .google.cloud.automl.v1.Model model = 4; + * @param \Google\Cloud\AutoMl\V1\Model $var + * @return $this + */ + public function setModel($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\Model::class); + $this->model = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/Dataset.php b/AutoMl/src/V1/Dataset.php new file mode 100644 index 000000000000..675995cb01c4 --- /dev/null +++ b/AutoMl/src/V1/Dataset.php @@ -0,0 +1,353 @@ +google.cloud.automl.v1.Dataset + */ +class Dataset extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The resource name of the dataset. + * Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}` + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Required. The name of the dataset to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. + * + * Generated from protobuf field string display_name = 2; + */ + private $display_name = ''; + /** + * User-provided description of the dataset. The description can be up to + * 25000 characters long. + * + * Generated from protobuf field string description = 3; + */ + private $description = ''; + /** + * Output only. The number of examples in the dataset. + * + * Generated from protobuf field int32 example_count = 21; + */ + private $example_count = 0; + /** + * Output only. Timestamp when this dataset was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 14; + */ + private $create_time = null; + /** + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * + * Generated from protobuf field string etag = 17; + */ + private $etag = ''; + /** + * Optional. The labels with user-defined metadata to organize your dataset. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 39; + */ + private $labels; + protected $dataset_metadata; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\TranslationDatasetMetadata $translation_dataset_metadata + * Metadata for a dataset used for translation. + * @type string $name + * Output only. The resource name of the dataset. + * Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}` + * @type string $display_name + * Required. The name of the dataset to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. + * @type string $description + * User-provided description of the dataset. The description can be up to + * 25000 characters long. + * @type int $example_count + * Output only. The number of examples in the dataset. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Timestamp when this dataset was created. + * @type string $etag + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * @type array|\Google\Protobuf\Internal\MapField $labels + * Optional. The labels with user-defined metadata to organize your dataset. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Dataset::initOnce(); + parent::__construct($data); + } + + /** + * Metadata for a dataset used for translation. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationDatasetMetadata translation_dataset_metadata = 23; + * @return \Google\Cloud\AutoMl\V1\TranslationDatasetMetadata + */ + public function getTranslationDatasetMetadata() + { + return $this->readOneof(23); + } + + /** + * Metadata for a dataset used for translation. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationDatasetMetadata translation_dataset_metadata = 23; + * @param \Google\Cloud\AutoMl\V1\TranslationDatasetMetadata $var + * @return $this + */ + public function setTranslationDatasetMetadata($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\TranslationDatasetMetadata::class); + $this->writeOneof(23, $var); + + return $this; + } + + /** + * Output only. The resource name of the dataset. + * Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}` + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The resource name of the dataset. + * Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}` + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The name of the dataset to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. + * + * Generated from protobuf field string display_name = 2; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * Required. The name of the dataset to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. + * + * Generated from protobuf field string display_name = 2; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * User-provided description of the dataset. The description can be up to + * 25000 characters long. + * + * Generated from protobuf field string description = 3; + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * User-provided description of the dataset. The description can be up to + * 25000 characters long. + * + * Generated from protobuf field string description = 3; + * @param string $var + * @return $this + */ + public function setDescription($var) + { + GPBUtil::checkString($var, True); + $this->description = $var; + + return $this; + } + + /** + * Output only. The number of examples in the dataset. + * + * Generated from protobuf field int32 example_count = 21; + * @return int + */ + public function getExampleCount() + { + return $this->example_count; + } + + /** + * Output only. The number of examples in the dataset. + * + * Generated from protobuf field int32 example_count = 21; + * @param int $var + * @return $this + */ + public function setExampleCount($var) + { + GPBUtil::checkInt32($var); + $this->example_count = $var; + + return $this; + } + + /** + * Output only. Timestamp when this dataset was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 14; + * @return \Google\Protobuf\Timestamp + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Output only. Timestamp when this dataset was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 14; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * + * Generated from protobuf field string etag = 17; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * + * Generated from protobuf field string etag = 17; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * Optional. The labels with user-defined metadata to organize your dataset. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 39; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Optional. The labels with user-defined metadata to organize your dataset. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 39; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + + /** + * @return string + */ + public function getDatasetMetadata() + { + return $this->whichOneof("dataset_metadata"); + } + +} + diff --git a/AutoMl/src/V1/DeleteDatasetRequest.php b/AutoMl/src/V1/DeleteDatasetRequest.php new file mode 100644 index 000000000000..9c9b23b7c7f6 --- /dev/null +++ b/AutoMl/src/V1/DeleteDatasetRequest.php @@ -0,0 +1,67 @@ +google.cloud.automl.v1.DeleteDatasetRequest + */ +class DeleteDatasetRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the dataset to delete. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The resource name of the dataset to delete. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the dataset to delete. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The resource name of the dataset to delete. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/DeleteModelRequest.php b/AutoMl/src/V1/DeleteModelRequest.php new file mode 100644 index 000000000000..8d93de645df1 --- /dev/null +++ b/AutoMl/src/V1/DeleteModelRequest.php @@ -0,0 +1,67 @@ +google.cloud.automl.v1.DeleteModelRequest + */ +class DeleteModelRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of the model being deleted. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Resource name of the model being deleted. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of the model being deleted. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Resource name of the model being deleted. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/DeleteOperationMetadata.php b/AutoMl/src/V1/DeleteOperationMetadata.php new file mode 100644 index 000000000000..9e8a8551ac12 --- /dev/null +++ b/AutoMl/src/V1/DeleteOperationMetadata.php @@ -0,0 +1,33 @@ +google.cloud.automl.v1.DeleteOperationMetadata + */ +class DeleteOperationMetadata extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Operations::initOnce(); + parent::__construct($data); + } + +} + diff --git a/AutoMl/src/V1/ExamplePayload.php b/AutoMl/src/V1/ExamplePayload.php new file mode 100644 index 000000000000..6e268887e290 --- /dev/null +++ b/AutoMl/src/V1/ExamplePayload.php @@ -0,0 +1,70 @@ +google.cloud.automl.v1.ExamplePayload + */ +class ExamplePayload extends \Google\Protobuf\Internal\Message +{ + protected $payload; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\TextSnippet $text_snippet + * Example text. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\DataItems::initOnce(); + parent::__construct($data); + } + + /** + * Example text. + * + * Generated from protobuf field .google.cloud.automl.v1.TextSnippet text_snippet = 2; + * @return \Google\Cloud\AutoMl\V1\TextSnippet + */ + public function getTextSnippet() + { + return $this->readOneof(2); + } + + /** + * Example text. + * + * Generated from protobuf field .google.cloud.automl.v1.TextSnippet text_snippet = 2; + * @param \Google\Cloud\AutoMl\V1\TextSnippet $var + * @return $this + */ + public function setTextSnippet($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\TextSnippet::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * @return string + */ + public function getPayload() + { + return $this->whichOneof("payload"); + } + +} + diff --git a/AutoMl/src/V1/ExportDataRequest.php b/AutoMl/src/V1/ExportDataRequest.php new file mode 100644 index 000000000000..882993b2f3dc --- /dev/null +++ b/AutoMl/src/V1/ExportDataRequest.php @@ -0,0 +1,101 @@ +google.cloud.automl.v1.ExportDataRequest + */ +class ExportDataRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the dataset. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Required. The desired output location. + * + * Generated from protobuf field .google.cloud.automl.v1.OutputConfig output_config = 3; + */ + private $output_config = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the dataset. + * @type \Google\Cloud\AutoMl\V1\OutputConfig $output_config + * Required. The desired output location. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the dataset. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The resource name of the dataset. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The desired output location. + * + * Generated from protobuf field .google.cloud.automl.v1.OutputConfig output_config = 3; + * @return \Google\Cloud\AutoMl\V1\OutputConfig + */ + public function getOutputConfig() + { + return $this->output_config; + } + + /** + * Required. The desired output location. + * + * Generated from protobuf field .google.cloud.automl.v1.OutputConfig output_config = 3; + * @param \Google\Cloud\AutoMl\V1\OutputConfig $var + * @return $this + */ + public function setOutputConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\OutputConfig::class); + $this->output_config = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/Gapic/AutoMlGapicClient.php b/AutoMl/src/V1/Gapic/AutoMlGapicClient.php new file mode 100644 index 000000000000..49f00c237998 --- /dev/null +++ b/AutoMl/src/V1/Gapic/AutoMlGapicClient.php @@ -0,0 +1,1425 @@ +locationName('[PROJECT]', '[LOCATION]'); + * $dataset = new Google\Cloud\AutoMl\V1\Dataset(); + * $response = $autoMlClient->createDataset($formattedParent, $dataset); + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To assist + * with these names, this class includes a format method for each type of name, and additionally + * a parseName method to extract the individual identifiers contained within formatted names + * that are returned by the API. + * + * @experimental + */ +class AutoMlGapicClient +{ + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.automl.v1.AutoMl'; + + /** + * The default address of the service. + */ + const SERVICE_ADDRESS = 'automl.googleapis.com'; + + /** + * The default port of the service. + */ + const DEFAULT_SERVICE_PORT = 443; + + /** + * The name of the code generator, to be included in the agent header. + */ + const CODEGEN_NAME = 'gapic'; + + /** + * The default scopes required by the service. + */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + private static $datasetNameTemplate; + private static $locationNameTemplate; + private static $modelNameTemplate; + private static $modelEvaluationNameTemplate; + private static $pathTemplateMap; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__.'/../resources/auto_ml_client_config.json', + 'descriptorsConfigPath' => __DIR__.'/../resources/auto_ml_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__.'/../resources/auto_ml_grpc_config.json', + 'credentialsConfig' => [ + 'scopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__.'/../resources/auto_ml_rest_client_config.php', + ], + ], + ]; + } + + private static function getDatasetNameTemplate() + { + if (null == self::$datasetNameTemplate) { + self::$datasetNameTemplate = new PathTemplate('projects/{project}/locations/{location}/datasets/{dataset}'); + } + + return self::$datasetNameTemplate; + } + + private static function getLocationNameTemplate() + { + if (null == self::$locationNameTemplate) { + self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); + } + + return self::$locationNameTemplate; + } + + private static function getModelNameTemplate() + { + if (null == self::$modelNameTemplate) { + self::$modelNameTemplate = new PathTemplate('projects/{project}/locations/{location}/models/{model}'); + } + + return self::$modelNameTemplate; + } + + private static function getModelEvaluationNameTemplate() + { + if (null == self::$modelEvaluationNameTemplate) { + self::$modelEvaluationNameTemplate = new PathTemplate('projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation}'); + } + + return self::$modelEvaluationNameTemplate; + } + + private static function getPathTemplateMap() + { + if (null == self::$pathTemplateMap) { + self::$pathTemplateMap = [ + 'dataset' => self::getDatasetNameTemplate(), + 'location' => self::getLocationNameTemplate(), + 'model' => self::getModelNameTemplate(), + 'modelEvaluation' => self::getModelEvaluationNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent + * a dataset resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * + * @return string The formatted dataset resource. + * @experimental + */ + public static function datasetName($project, $location, $dataset) + { + return self::getDatasetNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent + * a location resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + * @experimental + */ + public static function locationName($project, $location) + { + return self::getLocationNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent + * a model resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + * @experimental + */ + public static function modelName($project, $location, $model) + { + return self::getModelNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent + * a model_evaluation resource. + * + * @param string $project + * @param string $location + * @param string $model + * @param string $modelEvaluation + * + * @return string The formatted model_evaluation resource. + * @experimental + */ + public static function modelEvaluationName($project, $location, $model, $modelEvaluation) + { + return self::getModelEvaluationNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + 'model_evaluation' => $modelEvaluation, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataset: projects/{project}/locations/{location}/datasets/{dataset} + * - location: projects/{project}/locations/{location} + * - model: projects/{project}/locations/{location}/models/{model} + * - modelEvaluation: projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation}. + * + * The optional $template argument can be supplied to specify a particular pattern, and must + * match one of the templates listed above. If no $template argument is provided, or if the + * $template argument does not match one of the templates listed, then parseName will check + * each of the supported templates, and return the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * @experimental + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started + * by a long running API method. If $methodName is not provided, or does + * not match a long running API method, then the operation can still be + * resumed, but the OperationResponse object will not deserialize the + * final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + + return $operation; + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $serviceAddress + * **Deprecated**. This option will be removed in a future major release. Please + * utilize the `$apiEndpoint` option instead. + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'automl.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the client. + * For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()}. + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either a + * path to a JSON file, or a PHP array containing the decoded JSON data. + * By default this settings points to the default client config file, which is provided + * in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string `rest` + * or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already instantiated + * {@see \Google\ApiCore\Transport\TransportInterface} object. Note that when this + * object is provided, any settings in $transportConfig, and any `$apiEndpoint` + * setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...] + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * } + * + * @throws ValidationException + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** + * Creates a dataset. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]'); + * $dataset = new Google\Cloud\AutoMl\V1\Dataset(); + * $response = $autoMlClient->createDataset($formattedParent, $dataset); + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $parent The resource name of the project to create the dataset for. + * @param Dataset $dataset The dataset to create. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\LongRunning\Operation + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function createDataset($parent, $dataset, array $optionalArgs = []) + { + $request = new CreateDatasetRequest(); + $request->setParent($parent); + $request->setDataset($dataset); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'CreateDataset', + Operation::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Updates a dataset. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $dataset = new Google\Cloud\AutoMl\V1\Dataset(); + * $updateMask = new FieldMask(); + * $response = $autoMlClient->updateDataset($dataset, $updateMask); + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param Dataset $dataset The dataset which replaces the resource on the server. + * @param FieldMask $updateMask Required. The update mask applies to the resource. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\AutoMl\V1\Dataset + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function updateDataset($dataset, $updateMask, array $optionalArgs = []) + { + $request = new UpdateDatasetRequest(); + $request->setDataset($dataset); + $request->setUpdateMask($updateMask); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'dataset.name' => $request->getDataset()->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'UpdateDataset', + Dataset::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Gets a dataset. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + * $response = $autoMlClient->getDataset($formattedName); + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $name The resource name of the dataset to retrieve. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\AutoMl\V1\Dataset + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function getDataset($name, array $optionalArgs = []) + { + $request = new GetDatasetRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'GetDataset', + Dataset::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Lists datasets in a project. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $autoMlClient->listDatasets($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * + * + * // Alternatively: + * + * // Iterate through all elements + * $pagedResponse = $autoMlClient->listDatasets($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $parent The resource name of the project from which to list datasets. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * An expression for filtering the results of the request. + * + * * `dataset_metadata` - for existence of the case (e.g. + * image_classification_dataset_metadata:*). + * Some examples of using the filter are: + * + * * `translation_dataset_metadata:*` --> The dataset has + * translation_dataset_metadata. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function listDatasets($parent, array $optionalArgs = []) + { + $request = new ListDatasetsRequest(); + $request->setParent($parent); + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->getPagedListResponse( + 'ListDatasets', + $optionalArgs, + ListDatasetsResponse::class, + $request + ); + } + + /** + * Deletes a dataset and all of its contents. + * Returns empty response in the + * [response][google.longrunning.Operation.response] field when it completes, + * and `delete_details` in the + * [metadata][google.longrunning.Operation.metadata] field. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + * $operationResponse = $autoMlClient->deleteDataset($formattedName); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * + * + * // Alternatively: + * + * // start the operation, keep the operation name, and resume later + * $operationResponse = $autoMlClient->deleteDataset($formattedName); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $autoMlClient->resumeOperation($operationName, 'deleteDataset'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $name The resource name of the dataset to delete. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function deleteDataset($name, array $optionalArgs = []) + { + $request = new DeleteDatasetRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startOperationsCall( + 'DeleteDataset', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + + /** + * Imports data into a dataset. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + * $inputConfig = new InputConfig(); + * $operationResponse = $autoMlClient->importData($formattedName, $inputConfig); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * + * + * // Alternatively: + * + * // start the operation, keep the operation name, and resume later + * $operationResponse = $autoMlClient->importData($formattedName, $inputConfig); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $autoMlClient->resumeOperation($operationName, 'importData'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $name Required. Dataset name. Dataset must already exist. All imported + * annotations and examples will be added. + * @param InputConfig $inputConfig Required. The desired input location and its domain specific semantics, + * if any. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function importData($name, $inputConfig, array $optionalArgs = []) + { + $request = new ImportDataRequest(); + $request->setName($name); + $request->setInputConfig($inputConfig); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startOperationsCall( + 'ImportData', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + + /** + * Exports dataset's data to the provided output location. + * Returns an empty response in the + * [response][google.longrunning.Operation.response] field when it completes. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + * $outputConfig = new OutputConfig(); + * $operationResponse = $autoMlClient->exportData($formattedName, $outputConfig); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * + * + * // Alternatively: + * + * // start the operation, keep the operation name, and resume later + * $operationResponse = $autoMlClient->exportData($formattedName, $outputConfig); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $autoMlClient->resumeOperation($operationName, 'exportData'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the dataset. + * @param OutputConfig $outputConfig Required. The desired output location. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function exportData($name, $outputConfig, array $optionalArgs = []) + { + $request = new ExportDataRequest(); + $request->setName($name); + $request->setOutputConfig($outputConfig); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startOperationsCall( + 'ExportData', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + + /** + * Creates a model. + * Returns a Model in the [response][google.longrunning.Operation.response] + * field when it completes. + * When you create a model, several model evaluations are created for it: + * a global evaluation, and one evaluation for each annotation spec. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]'); + * $model = new Model(); + * $operationResponse = $autoMlClient->createModel($formattedParent, $model); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * + * + * // Alternatively: + * + * // start the operation, keep the operation name, and resume later + * $operationResponse = $autoMlClient->createModel($formattedParent, $model); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $autoMlClient->resumeOperation($operationName, 'createModel'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $parent Resource name of the parent project where the model is being created. + * @param Model $model The model to create. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function createModel($parent, $model, array $optionalArgs = []) + { + $request = new CreateModelRequest(); + $request->setParent($parent); + $request->setModel($model); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startOperationsCall( + 'CreateModel', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + + /** + * Gets a model. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + * $response = $autoMlClient->getModel($formattedName); + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $name Resource name of the model. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\AutoMl\V1\Model + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function getModel($name, array $optionalArgs = []) + { + $request = new GetModelRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'GetModel', + Model::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Updates a model. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $model = new Model(); + * $updateMask = new FieldMask(); + * $response = $autoMlClient->updateModel($model, $updateMask); + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param Model $model The model which replaces the resource on the server. + * @param FieldMask $updateMask Required. The update mask applies to the resource. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\AutoMl\V1\Model + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function updateModel($model, $updateMask, array $optionalArgs = []) + { + $request = new UpdateModelRequest(); + $request->setModel($model); + $request->setUpdateMask($updateMask); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'model.name' => $request->getModel()->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'UpdateModel', + Model::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Lists models. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $autoMlClient->listModels($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * + * + * // Alternatively: + * + * // Iterate through all elements + * $pagedResponse = $autoMlClient->listModels($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $parent Resource name of the project, from which to list the models. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * An expression for filtering the results of the request. + * + * * `model_metadata` - for existence of the case (e.g. + * video_classification_model_metadata:*). + * * `dataset_id` - for = or !=. Some examples of using the filter are: + * + * * `image_classification_model_metadata:*` --> The model has + * image_classification_model_metadata. + * * `dataset_id=5` --> The model was created from a dataset with ID 5. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function listModels($parent, array $optionalArgs = []) + { + $request = new ListModelsRequest(); + $request->setParent($parent); + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->getPagedListResponse( + 'ListModels', + $optionalArgs, + ListModelsResponse::class, + $request + ); + } + + /** + * Deletes a model. + * Returns `google.protobuf.Empty` in the + * [response][google.longrunning.Operation.response] field when it completes, + * and `delete_details` in the + * [metadata][google.longrunning.Operation.metadata] field. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + * $operationResponse = $autoMlClient->deleteModel($formattedName); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * + * + * // Alternatively: + * + * // start the operation, keep the operation name, and resume later + * $operationResponse = $autoMlClient->deleteModel($formattedName); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $autoMlClient->resumeOperation($operationName, 'deleteModel'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $name Resource name of the model being deleted. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function deleteModel($name, array $optionalArgs = []) + { + $request = new DeleteModelRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startOperationsCall( + 'DeleteModel', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + + /** + * Gets a model evaluation. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedName = $autoMlClient->modelEvaluationName('[PROJECT]', '[LOCATION]', '[MODEL]', '[MODEL_EVALUATION]'); + * $response = $autoMlClient->getModelEvaluation($formattedName); + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $name Resource name for the model evaluation. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\AutoMl\V1\ModelEvaluation + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function getModelEvaluation($name, array $optionalArgs = []) + { + $request = new GetModelEvaluationRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'GetModelEvaluation', + ModelEvaluation::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Lists model evaluations. + * + * Sample code: + * ``` + * $autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient(); + * try { + * $formattedParent = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + * $filter = ''; + * // Iterate over pages of elements + * $pagedResponse = $autoMlClient->listModelEvaluations($formattedParent, $filter); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * + * + * // Alternatively: + * + * // Iterate through all elements + * $pagedResponse = $autoMlClient->listModelEvaluations($formattedParent, $filter); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $autoMlClient->close(); + * } + * ``` + * + * @param string $parent Resource name of the model to list the model evaluations for. + * If modelId is set as "-", this will list model evaluations from across all + * models of the parent location. + * @param string $filter An expression for filtering the results of the request. + * + * * `annotation_spec_id` - for =, != or existence. See example below for + * the last. + * + * Some examples of using the filter are: + * + * * `annotation_spec_id!=4` --> The model evaluation was done for + * annotation spec with ID different than 4. + * * `NOT annotation_spec_id:*` --> The model evaluation was done for + * aggregate of all annotation specs. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function listModelEvaluations($parent, $filter, array $optionalArgs = []) + { + $request = new ListModelEvaluationsRequest(); + $request->setParent($parent); + $request->setFilter($filter); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->getPagedListResponse( + 'ListModelEvaluations', + $optionalArgs, + ListModelEvaluationsResponse::class, + $request + ); + } +} diff --git a/AutoMl/src/V1/Gapic/PredictionServiceGapicClient.php b/AutoMl/src/V1/Gapic/PredictionServiceGapicClient.php new file mode 100644 index 000000000000..dc1d5dd9040d --- /dev/null +++ b/AutoMl/src/V1/Gapic/PredictionServiceGapicClient.php @@ -0,0 +1,326 @@ +modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + * $payload = new ExamplePayload(); + * $response = $predictionServiceClient->predict($formattedName, $payload); + * } finally { + * $predictionServiceClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To assist + * with these names, this class includes a format method for each type of name, and additionally + * a parseName method to extract the individual identifiers contained within formatted names + * that are returned by the API. + * + * @experimental + */ +class PredictionServiceGapicClient +{ + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.automl.v1.PredictionService'; + + /** + * The default address of the service. + */ + const SERVICE_ADDRESS = 'automl.googleapis.com'; + + /** + * The default port of the service. + */ + const DEFAULT_SERVICE_PORT = 443; + + /** + * The name of the code generator, to be included in the agent header. + */ + const CODEGEN_NAME = 'gapic'; + + /** + * The default scopes required by the service. + */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + private static $modelNameTemplate; + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__.'/../resources/prediction_service_client_config.json', + 'descriptorsConfigPath' => __DIR__.'/../resources/prediction_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__.'/../resources/prediction_service_grpc_config.json', + 'credentialsConfig' => [ + 'scopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__.'/../resources/prediction_service_rest_client_config.php', + ], + ], + ]; + } + + private static function getModelNameTemplate() + { + if (null == self::$modelNameTemplate) { + self::$modelNameTemplate = new PathTemplate('projects/{project}/locations/{location}/models/{model}'); + } + + return self::$modelNameTemplate; + } + + private static function getPathTemplateMap() + { + if (null == self::$pathTemplateMap) { + self::$pathTemplateMap = [ + 'model' => self::getModelNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent + * a model resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + * @experimental + */ + public static function modelName($project, $location, $model) + { + return self::getModelNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - model: projects/{project}/locations/{location}/models/{model}. + * + * The optional $template argument can be supplied to specify a particular pattern, and must + * match one of the templates listed above. If no $template argument is provided, or if the + * $template argument does not match one of the templates listed, then parseName will check + * each of the supported templates, and return the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * @experimental + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $serviceAddress + * **Deprecated**. This option will be removed in a future major release. Please + * utilize the `$apiEndpoint` option instead. + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'automl.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the client. + * For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()}. + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either a + * path to a JSON file, or a PHP array containing the decoded JSON data. + * By default this settings points to the default client config file, which is provided + * in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string `rest` + * or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already instantiated + * {@see \Google\ApiCore\Transport\TransportInterface} object. Note that when this + * object is provided, any settings in $transportConfig, and any `$apiEndpoint` + * setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...] + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * } + * + * @throws ValidationException + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Perform an online prediction. The prediction result will be directly + * returned in the response. + * Available for following ML problems, and their expected request payloads: + * * Translation - TextSnippet, content up to 25,000 characters, UTF-8 + * encoded. + * + * Sample code: + * ``` + * $predictionServiceClient = new Google\Cloud\AutoMl\V1\PredictionServiceClient(); + * try { + * $formattedName = $predictionServiceClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + * $payload = new ExamplePayload(); + * $response = $predictionServiceClient->predict($formattedName, $payload); + * } finally { + * $predictionServiceClient->close(); + * } + * ``` + * + * @param string $name Name of the model requested to serve the prediction. + * @param ExamplePayload $payload Required. Payload to perform a prediction on. The payload must match the + * problem type that the model was trained to solve. + * @param array $optionalArgs { + * Optional. + * + * @type array $params + * Additional domain-specific parameters, any string must be up to 25000 + * characters long. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\AutoMl\V1\PredictResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function predict($name, $payload, array $optionalArgs = []) + { + $request = new PredictRequest(); + $request->setName($name); + $request->setPayload($payload); + if (isset($optionalArgs['params'])) { + $request->setParams($optionalArgs['params']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'Predict', + PredictResponse::class, + $optionalArgs, + $request + )->wait(); + } +} diff --git a/AutoMl/src/V1/GcsDestination.php b/AutoMl/src/V1/GcsDestination.php new file mode 100644 index 000000000000..4331dd458f98 --- /dev/null +++ b/AutoMl/src/V1/GcsDestination.php @@ -0,0 +1,87 @@ +google.cloud.automl.v1.GcsDestination + */ +class GcsDestination extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Google Cloud Storage URI to output directory, up to 2000 + * characters long. + * Accepted forms: + * * Prefix path: gs://bucket/directory + * The requesting user must have write permission to the bucket. + * The directory is created if it doesn't exist. + * + * Generated from protobuf field string output_uri_prefix = 1; + */ + private $output_uri_prefix = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $output_uri_prefix + * Required. Google Cloud Storage URI to output directory, up to 2000 + * characters long. + * Accepted forms: + * * Prefix path: gs://bucket/directory + * The requesting user must have write permission to the bucket. + * The directory is created if it doesn't exist. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Io::initOnce(); + parent::__construct($data); + } + + /** + * Required. Google Cloud Storage URI to output directory, up to 2000 + * characters long. + * Accepted forms: + * * Prefix path: gs://bucket/directory + * The requesting user must have write permission to the bucket. + * The directory is created if it doesn't exist. + * + * Generated from protobuf field string output_uri_prefix = 1; + * @return string + */ + public function getOutputUriPrefix() + { + return $this->output_uri_prefix; + } + + /** + * Required. Google Cloud Storage URI to output directory, up to 2000 + * characters long. + * Accepted forms: + * * Prefix path: gs://bucket/directory + * The requesting user must have write permission to the bucket. + * The directory is created if it doesn't exist. + * + * Generated from protobuf field string output_uri_prefix = 1; + * @param string $var + * @return $this + */ + public function setOutputUriPrefix($var) + { + GPBUtil::checkString($var, True); + $this->output_uri_prefix = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/GcsSource.php b/AutoMl/src/V1/GcsSource.php new file mode 100644 index 000000000000..31204b6db4ed --- /dev/null +++ b/AutoMl/src/V1/GcsSource.php @@ -0,0 +1,75 @@ +google.cloud.automl.v1.GcsSource + */ +class GcsSource extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Google Cloud Storage URIs to input files, up to 2000 characters + * long. Accepted forms: + * * Full object path, e.g. gs://bucket/directory/object.csv + * + * Generated from protobuf field repeated string input_uris = 1; + */ + private $input_uris; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string[]|\Google\Protobuf\Internal\RepeatedField $input_uris + * Required. Google Cloud Storage URIs to input files, up to 2000 characters + * long. Accepted forms: + * * Full object path, e.g. gs://bucket/directory/object.csv + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Io::initOnce(); + parent::__construct($data); + } + + /** + * Required. Google Cloud Storage URIs to input files, up to 2000 characters + * long. Accepted forms: + * * Full object path, e.g. gs://bucket/directory/object.csv + * + * Generated from protobuf field repeated string input_uris = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getInputUris() + { + return $this->input_uris; + } + + /** + * Required. Google Cloud Storage URIs to input files, up to 2000 characters + * long. Accepted forms: + * * Full object path, e.g. gs://bucket/directory/object.csv + * + * Generated from protobuf field repeated string input_uris = 1; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setInputUris($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->input_uris = $arr; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/GetDatasetRequest.php b/AutoMl/src/V1/GetDatasetRequest.php new file mode 100644 index 000000000000..57da0f80ec96 --- /dev/null +++ b/AutoMl/src/V1/GetDatasetRequest.php @@ -0,0 +1,67 @@ +google.cloud.automl.v1.GetDatasetRequest + */ +class GetDatasetRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the dataset to retrieve. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The resource name of the dataset to retrieve. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the dataset to retrieve. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The resource name of the dataset to retrieve. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/GetModelEvaluationRequest.php b/AutoMl/src/V1/GetModelEvaluationRequest.php new file mode 100644 index 000000000000..45076d289d73 --- /dev/null +++ b/AutoMl/src/V1/GetModelEvaluationRequest.php @@ -0,0 +1,67 @@ +google.cloud.automl.v1.GetModelEvaluationRequest + */ +class GetModelEvaluationRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name for the model evaluation. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Resource name for the model evaluation. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name for the model evaluation. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Resource name for the model evaluation. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/GetModelRequest.php b/AutoMl/src/V1/GetModelRequest.php new file mode 100644 index 000000000000..085850f9746c --- /dev/null +++ b/AutoMl/src/V1/GetModelRequest.php @@ -0,0 +1,67 @@ +google.cloud.automl.v1.GetModelRequest + */ +class GetModelRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of the model. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Resource name of the model. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of the model. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Resource name of the model. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/ImportDataRequest.php b/AutoMl/src/V1/ImportDataRequest.php new file mode 100644 index 000000000000..3541895c4c70 --- /dev/null +++ b/AutoMl/src/V1/ImportDataRequest.php @@ -0,0 +1,109 @@ +google.cloud.automl.v1.ImportDataRequest + */ +class ImportDataRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Dataset name. Dataset must already exist. All imported + * annotations and examples will be added. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Required. The desired input location and its domain specific semantics, + * if any. + * + * Generated from protobuf field .google.cloud.automl.v1.InputConfig input_config = 3; + */ + private $input_config = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Dataset name. Dataset must already exist. All imported + * annotations and examples will be added. + * @type \Google\Cloud\AutoMl\V1\InputConfig $input_config + * Required. The desired input location and its domain specific semantics, + * if any. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. Dataset name. Dataset must already exist. All imported + * annotations and examples will be added. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Dataset name. Dataset must already exist. All imported + * annotations and examples will be added. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The desired input location and its domain specific semantics, + * if any. + * + * Generated from protobuf field .google.cloud.automl.v1.InputConfig input_config = 3; + * @return \Google\Cloud\AutoMl\V1\InputConfig + */ + public function getInputConfig() + { + return $this->input_config; + } + + /** + * Required. The desired input location and its domain specific semantics, + * if any. + * + * Generated from protobuf field .google.cloud.automl.v1.InputConfig input_config = 3; + * @param \Google\Cloud\AutoMl\V1\InputConfig $var + * @return $this + */ + public function setInputConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\InputConfig::class); + $this->input_config = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/InputConfig.php b/AutoMl/src/V1/InputConfig.php new file mode 100644 index 000000000000..da9ef5c2293e --- /dev/null +++ b/AutoMl/src/V1/InputConfig.php @@ -0,0 +1,134 @@ +google.cloud.automl.v1.InputConfig + */ +class InputConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Additional domain-specific parameters describing the semantic of the + * imported data, any string must be up to 25000 + * characters long. + * + * Generated from protobuf field map params = 2; + */ + private $params; + protected $source; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\GcsSource $gcs_source + * The Google Cloud Storage location for the input content. + * In ImportData, the gcs_source points to a csv with structure described in + * the comment. + * @type array|\Google\Protobuf\Internal\MapField $params + * Additional domain-specific parameters describing the semantic of the + * imported data, any string must be up to 25000 + * characters long. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Io::initOnce(); + parent::__construct($data); + } + + /** + * The Google Cloud Storage location for the input content. + * In ImportData, the gcs_source points to a csv with structure described in + * the comment. + * + * Generated from protobuf field .google.cloud.automl.v1.GcsSource gcs_source = 1; + * @return \Google\Cloud\AutoMl\V1\GcsSource + */ + public function getGcsSource() + { + return $this->readOneof(1); + } + + /** + * The Google Cloud Storage location for the input content. + * In ImportData, the gcs_source points to a csv with structure described in + * the comment. + * + * Generated from protobuf field .google.cloud.automl.v1.GcsSource gcs_source = 1; + * @param \Google\Cloud\AutoMl\V1\GcsSource $var + * @return $this + */ + public function setGcsSource($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\GcsSource::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Additional domain-specific parameters describing the semantic of the + * imported data, any string must be up to 25000 + * characters long. + * + * Generated from protobuf field map params = 2; + * @return \Google\Protobuf\Internal\MapField + */ + public function getParams() + { + return $this->params; + } + + /** + * Additional domain-specific parameters describing the semantic of the + * imported data, any string must be up to 25000 + * characters long. + * + * Generated from protobuf field map params = 2; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setParams($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->params = $arr; + + return $this; + } + + /** + * @return string + */ + public function getSource() + { + return $this->whichOneof("source"); + } + +} + diff --git a/AutoMl/src/V1/ListDatasetsRequest.php b/AutoMl/src/V1/ListDatasetsRequest.php new file mode 100644 index 000000000000..b71820331da3 --- /dev/null +++ b/AutoMl/src/V1/ListDatasetsRequest.php @@ -0,0 +1,205 @@ +google.cloud.automl.v1.ListDatasetsRequest + */ +class ListDatasetsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the project from which to list datasets. + * + * Generated from protobuf field string parent = 1; + */ + private $parent = ''; + /** + * An expression for filtering the results of the request. + * * `dataset_metadata` - for existence of the case (e.g. + * image_classification_dataset_metadata:*). + * Some examples of using the filter are: + * * `translation_dataset_metadata:*` --> The dataset has + * translation_dataset_metadata. + * + * Generated from protobuf field string filter = 3; + */ + private $filter = ''; + /** + * Requested page size. Server may return fewer results than requested. + * If unspecified, server will pick a default size. + * + * Generated from protobuf field int32 page_size = 4; + */ + private $page_size = 0; + /** + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListDatasetsResponse.next_page_token][google.cloud.automl.v1.ListDatasetsResponse.next_page_token] of the previous + * [AutoMl.ListDatasets][google.cloud.automl.v1.AutoMl.ListDatasets] call. + * + * Generated from protobuf field string page_token = 6; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * The resource name of the project from which to list datasets. + * @type string $filter + * An expression for filtering the results of the request. + * * `dataset_metadata` - for existence of the case (e.g. + * image_classification_dataset_metadata:*). + * Some examples of using the filter are: + * * `translation_dataset_metadata:*` --> The dataset has + * translation_dataset_metadata. + * @type int $page_size + * Requested page size. Server may return fewer results than requested. + * If unspecified, server will pick a default size. + * @type string $page_token + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListDatasetsResponse.next_page_token][google.cloud.automl.v1.ListDatasetsResponse.next_page_token] of the previous + * [AutoMl.ListDatasets][google.cloud.automl.v1.AutoMl.ListDatasets] call. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the project from which to list datasets. + * + * Generated from protobuf field string parent = 1; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * The resource name of the project from which to list datasets. + * + * Generated from protobuf field string parent = 1; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * An expression for filtering the results of the request. + * * `dataset_metadata` - for existence of the case (e.g. + * image_classification_dataset_metadata:*). + * Some examples of using the filter are: + * * `translation_dataset_metadata:*` --> The dataset has + * translation_dataset_metadata. + * + * Generated from protobuf field string filter = 3; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression for filtering the results of the request. + * * `dataset_metadata` - for existence of the case (e.g. + * image_classification_dataset_metadata:*). + * Some examples of using the filter are: + * * `translation_dataset_metadata:*` --> The dataset has + * translation_dataset_metadata. + * + * Generated from protobuf field string filter = 3; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Requested page size. Server may return fewer results than requested. + * If unspecified, server will pick a default size. + * + * Generated from protobuf field int32 page_size = 4; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Requested page size. Server may return fewer results than requested. + * If unspecified, server will pick a default size. + * + * Generated from protobuf field int32 page_size = 4; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListDatasetsResponse.next_page_token][google.cloud.automl.v1.ListDatasetsResponse.next_page_token] of the previous + * [AutoMl.ListDatasets][google.cloud.automl.v1.AutoMl.ListDatasets] call. + * + * Generated from protobuf field string page_token = 6; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListDatasetsResponse.next_page_token][google.cloud.automl.v1.ListDatasetsResponse.next_page_token] of the previous + * [AutoMl.ListDatasets][google.cloud.automl.v1.AutoMl.ListDatasets] call. + * + * Generated from protobuf field string page_token = 6; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/ListDatasetsResponse.php b/AutoMl/src/V1/ListDatasetsResponse.php new file mode 100644 index 000000000000..9d7b4fbfd214 --- /dev/null +++ b/AutoMl/src/V1/ListDatasetsResponse.php @@ -0,0 +1,105 @@ +google.cloud.automl.v1.ListDatasetsResponse + */ +class ListDatasetsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The datasets read. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.Dataset datasets = 1; + */ + private $datasets; + /** + * A token to retrieve next page of results. + * Pass to [ListDatasetsRequest.page_token][google.cloud.automl.v1.ListDatasetsRequest.page_token] to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\Dataset[]|\Google\Protobuf\Internal\RepeatedField $datasets + * The datasets read. + * @type string $next_page_token + * A token to retrieve next page of results. + * Pass to [ListDatasetsRequest.page_token][google.cloud.automl.v1.ListDatasetsRequest.page_token] to obtain that page. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The datasets read. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.Dataset datasets = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDatasets() + { + return $this->datasets; + } + + /** + * The datasets read. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.Dataset datasets = 1; + * @param \Google\Cloud\AutoMl\V1\Dataset[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDatasets($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1\Dataset::class); + $this->datasets = $arr; + + return $this; + } + + /** + * A token to retrieve next page of results. + * Pass to [ListDatasetsRequest.page_token][google.cloud.automl.v1.ListDatasetsRequest.page_token] to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token to retrieve next page of results. + * Pass to [ListDatasetsRequest.page_token][google.cloud.automl.v1.ListDatasetsRequest.page_token] to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/ListModelEvaluationsRequest.php b/AutoMl/src/V1/ListModelEvaluationsRequest.php new file mode 100644 index 000000000000..1e061318f5cc --- /dev/null +++ b/AutoMl/src/V1/ListModelEvaluationsRequest.php @@ -0,0 +1,217 @@ +google.cloud.automl.v1.ListModelEvaluationsRequest + */ +class ListModelEvaluationsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of the model to list the model evaluations for. + * If modelId is set as "-", this will list model evaluations from across all + * models of the parent location. + * + * Generated from protobuf field string parent = 1; + */ + private $parent = ''; + /** + * An expression for filtering the results of the request. + * * `annotation_spec_id` - for =, != or existence. See example below for + * the last. + * Some examples of using the filter are: + * * `annotation_spec_id!=4` --> The model evaluation was done for + * annotation spec with ID different than 4. + * * `NOT annotation_spec_id:*` --> The model evaluation was done for + * aggregate of all annotation specs. + * + * Generated from protobuf field string filter = 3; + */ + private $filter = ''; + /** + * Requested page size. + * + * Generated from protobuf field int32 page_size = 4; + */ + private $page_size = 0; + /** + * A token identifying a page of results for the server to return. + * Typically obtained via + * [ListModelEvaluationsResponse.next_page_token][google.cloud.automl.v1.ListModelEvaluationsResponse.next_page_token] of the previous + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] call. + * + * Generated from protobuf field string page_token = 6; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Resource name of the model to list the model evaluations for. + * If modelId is set as "-", this will list model evaluations from across all + * models of the parent location. + * @type string $filter + * An expression for filtering the results of the request. + * * `annotation_spec_id` - for =, != or existence. See example below for + * the last. + * Some examples of using the filter are: + * * `annotation_spec_id!=4` --> The model evaluation was done for + * annotation spec with ID different than 4. + * * `NOT annotation_spec_id:*` --> The model evaluation was done for + * aggregate of all annotation specs. + * @type int $page_size + * Requested page size. + * @type string $page_token + * A token identifying a page of results for the server to return. + * Typically obtained via + * [ListModelEvaluationsResponse.next_page_token][google.cloud.automl.v1.ListModelEvaluationsResponse.next_page_token] of the previous + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] call. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of the model to list the model evaluations for. + * If modelId is set as "-", this will list model evaluations from across all + * models of the parent location. + * + * Generated from protobuf field string parent = 1; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Resource name of the model to list the model evaluations for. + * If modelId is set as "-", this will list model evaluations from across all + * models of the parent location. + * + * Generated from protobuf field string parent = 1; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * An expression for filtering the results of the request. + * * `annotation_spec_id` - for =, != or existence. See example below for + * the last. + * Some examples of using the filter are: + * * `annotation_spec_id!=4` --> The model evaluation was done for + * annotation spec with ID different than 4. + * * `NOT annotation_spec_id:*` --> The model evaluation was done for + * aggregate of all annotation specs. + * + * Generated from protobuf field string filter = 3; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression for filtering the results of the request. + * * `annotation_spec_id` - for =, != or existence. See example below for + * the last. + * Some examples of using the filter are: + * * `annotation_spec_id!=4` --> The model evaluation was done for + * annotation spec with ID different than 4. + * * `NOT annotation_spec_id:*` --> The model evaluation was done for + * aggregate of all annotation specs. + * + * Generated from protobuf field string filter = 3; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Requested page size. + * + * Generated from protobuf field int32 page_size = 4; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Requested page size. + * + * Generated from protobuf field int32 page_size = 4; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * A token identifying a page of results for the server to return. + * Typically obtained via + * [ListModelEvaluationsResponse.next_page_token][google.cloud.automl.v1.ListModelEvaluationsResponse.next_page_token] of the previous + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] call. + * + * Generated from protobuf field string page_token = 6; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * A token identifying a page of results for the server to return. + * Typically obtained via + * [ListModelEvaluationsResponse.next_page_token][google.cloud.automl.v1.ListModelEvaluationsResponse.next_page_token] of the previous + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] call. + * + * Generated from protobuf field string page_token = 6; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/ListModelEvaluationsResponse.php b/AutoMl/src/V1/ListModelEvaluationsResponse.php new file mode 100644 index 000000000000..9a6458b75075 --- /dev/null +++ b/AutoMl/src/V1/ListModelEvaluationsResponse.php @@ -0,0 +1,109 @@ +google.cloud.automl.v1.ListModelEvaluationsResponse + */ +class ListModelEvaluationsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * List of model evaluations in the requested page. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.ModelEvaluation model_evaluation = 1; + */ + private $model_evaluation; + /** + * A token to retrieve next page of results. + * Pass to the [ListModelEvaluationsRequest.page_token][google.cloud.automl.v1.ListModelEvaluationsRequest.page_token] field of a new + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] request to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\ModelEvaluation[]|\Google\Protobuf\Internal\RepeatedField $model_evaluation + * List of model evaluations in the requested page. + * @type string $next_page_token + * A token to retrieve next page of results. + * Pass to the [ListModelEvaluationsRequest.page_token][google.cloud.automl.v1.ListModelEvaluationsRequest.page_token] field of a new + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] request to obtain that page. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * List of model evaluations in the requested page. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.ModelEvaluation model_evaluation = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getModelEvaluation() + { + return $this->model_evaluation; + } + + /** + * List of model evaluations in the requested page. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.ModelEvaluation model_evaluation = 1; + * @param \Google\Cloud\AutoMl\V1\ModelEvaluation[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setModelEvaluation($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1\ModelEvaluation::class); + $this->model_evaluation = $arr; + + return $this; + } + + /** + * A token to retrieve next page of results. + * Pass to the [ListModelEvaluationsRequest.page_token][google.cloud.automl.v1.ListModelEvaluationsRequest.page_token] field of a new + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] request to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token to retrieve next page of results. + * Pass to the [ListModelEvaluationsRequest.page_token][google.cloud.automl.v1.ListModelEvaluationsRequest.page_token] field of a new + * [AutoMl.ListModelEvaluations][google.cloud.automl.v1.AutoMl.ListModelEvaluations] request to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/ListModelsRequest.php b/AutoMl/src/V1/ListModelsRequest.php new file mode 100644 index 000000000000..991cf40fe104 --- /dev/null +++ b/AutoMl/src/V1/ListModelsRequest.php @@ -0,0 +1,205 @@ +google.cloud.automl.v1.ListModelsRequest + */ +class ListModelsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of the project, from which to list the models. + * + * Generated from protobuf field string parent = 1; + */ + private $parent = ''; + /** + * An expression for filtering the results of the request. + * * `model_metadata` - for existence of the case (e.g. + * video_classification_model_metadata:*). + * * `dataset_id` - for = or !=. Some examples of using the filter are: + * * `image_classification_model_metadata:*` --> The model has + * image_classification_model_metadata. + * * `dataset_id=5` --> The model was created from a dataset with ID 5. + * + * Generated from protobuf field string filter = 3; + */ + private $filter = ''; + /** + * Requested page size. + * + * Generated from protobuf field int32 page_size = 4; + */ + private $page_size = 0; + /** + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListModelsResponse.next_page_token][google.cloud.automl.v1.ListModelsResponse.next_page_token] of the previous + * [AutoMl.ListModels][google.cloud.automl.v1.AutoMl.ListModels] call. + * + * Generated from protobuf field string page_token = 6; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Resource name of the project, from which to list the models. + * @type string $filter + * An expression for filtering the results of the request. + * * `model_metadata` - for existence of the case (e.g. + * video_classification_model_metadata:*). + * * `dataset_id` - for = or !=. Some examples of using the filter are: + * * `image_classification_model_metadata:*` --> The model has + * image_classification_model_metadata. + * * `dataset_id=5` --> The model was created from a dataset with ID 5. + * @type int $page_size + * Requested page size. + * @type string $page_token + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListModelsResponse.next_page_token][google.cloud.automl.v1.ListModelsResponse.next_page_token] of the previous + * [AutoMl.ListModels][google.cloud.automl.v1.AutoMl.ListModels] call. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of the project, from which to list the models. + * + * Generated from protobuf field string parent = 1; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Resource name of the project, from which to list the models. + * + * Generated from protobuf field string parent = 1; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * An expression for filtering the results of the request. + * * `model_metadata` - for existence of the case (e.g. + * video_classification_model_metadata:*). + * * `dataset_id` - for = or !=. Some examples of using the filter are: + * * `image_classification_model_metadata:*` --> The model has + * image_classification_model_metadata. + * * `dataset_id=5` --> The model was created from a dataset with ID 5. + * + * Generated from protobuf field string filter = 3; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression for filtering the results of the request. + * * `model_metadata` - for existence of the case (e.g. + * video_classification_model_metadata:*). + * * `dataset_id` - for = or !=. Some examples of using the filter are: + * * `image_classification_model_metadata:*` --> The model has + * image_classification_model_metadata. + * * `dataset_id=5` --> The model was created from a dataset with ID 5. + * + * Generated from protobuf field string filter = 3; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Requested page size. + * + * Generated from protobuf field int32 page_size = 4; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Requested page size. + * + * Generated from protobuf field int32 page_size = 4; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListModelsResponse.next_page_token][google.cloud.automl.v1.ListModelsResponse.next_page_token] of the previous + * [AutoMl.ListModels][google.cloud.automl.v1.AutoMl.ListModels] call. + * + * Generated from protobuf field string page_token = 6; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * A token identifying a page of results for the server to return + * Typically obtained via + * [ListModelsResponse.next_page_token][google.cloud.automl.v1.ListModelsResponse.next_page_token] of the previous + * [AutoMl.ListModels][google.cloud.automl.v1.AutoMl.ListModels] call. + * + * Generated from protobuf field string page_token = 6; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/ListModelsResponse.php b/AutoMl/src/V1/ListModelsResponse.php new file mode 100644 index 000000000000..56eb2713e1f1 --- /dev/null +++ b/AutoMl/src/V1/ListModelsResponse.php @@ -0,0 +1,105 @@ +google.cloud.automl.v1.ListModelsResponse + */ +class ListModelsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * List of models in the requested page. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.Model model = 1; + */ + private $model; + /** + * A token to retrieve next page of results. + * Pass to [ListModelsRequest.page_token][google.cloud.automl.v1.ListModelsRequest.page_token] to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\Model[]|\Google\Protobuf\Internal\RepeatedField $model + * List of models in the requested page. + * @type string $next_page_token + * A token to retrieve next page of results. + * Pass to [ListModelsRequest.page_token][google.cloud.automl.v1.ListModelsRequest.page_token] to obtain that page. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * List of models in the requested page. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.Model model = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getModel() + { + return $this->model; + } + + /** + * List of models in the requested page. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.Model model = 1; + * @param \Google\Cloud\AutoMl\V1\Model[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setModel($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1\Model::class); + $this->model = $arr; + + return $this; + } + + /** + * A token to retrieve next page of results. + * Pass to [ListModelsRequest.page_token][google.cloud.automl.v1.ListModelsRequest.page_token] to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token to retrieve next page of results. + * Pass to [ListModelsRequest.page_token][google.cloud.automl.v1.ListModelsRequest.page_token] to obtain that page. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/Model.php b/AutoMl/src/V1/Model.php new file mode 100644 index 000000000000..ae769d3967cf --- /dev/null +++ b/AutoMl/src/V1/Model.php @@ -0,0 +1,352 @@ +google.cloud.automl.v1.Model + */ +class Model extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Resource name of the model. + * Format: `projects/{project_id}/locations/{location_id}/models/{model_id}` + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Required. The name of the model to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. It must start with a letter. + * + * Generated from protobuf field string display_name = 2; + */ + private $display_name = ''; + /** + * Required. The resource ID of the dataset used to create the model. The dataset must + * come from the same ancestor project and location. + * + * Generated from protobuf field string dataset_id = 3; + */ + private $dataset_id = ''; + /** + * Output only. Timestamp when the model training finished and can be used for prediction. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 7; + */ + private $create_time = null; + /** + * Output only. Timestamp when this model was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 11; + */ + private $update_time = null; + /** + * Output only. Deployment state of the model. A model can only serve + * prediction requests after it gets deployed. + * + * Generated from protobuf field .google.cloud.automl.v1.Model.DeploymentState deployment_state = 8; + */ + private $deployment_state = 0; + /** + * Optional. The labels with user-defined metadata to organize your model. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 34; + */ + private $labels; + protected $model_metadata; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\TranslationModelMetadata $translation_model_metadata + * Metadata for translation models. + * @type string $name + * Output only. Resource name of the model. + * Format: `projects/{project_id}/locations/{location_id}/models/{model_id}` + * @type string $display_name + * Required. The name of the model to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. It must start with a letter. + * @type string $dataset_id + * Required. The resource ID of the dataset used to create the model. The dataset must + * come from the same ancestor project and location. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Timestamp when the model training finished and can be used for prediction. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Timestamp when this model was last updated. + * @type int $deployment_state + * Output only. Deployment state of the model. A model can only serve + * prediction requests after it gets deployed. + * @type array|\Google\Protobuf\Internal\MapField $labels + * Optional. The labels with user-defined metadata to organize your model. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Model::initOnce(); + parent::__construct($data); + } + + /** + * Metadata for translation models. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationModelMetadata translation_model_metadata = 15; + * @return \Google\Cloud\AutoMl\V1\TranslationModelMetadata + */ + public function getTranslationModelMetadata() + { + return $this->readOneof(15); + } + + /** + * Metadata for translation models. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationModelMetadata translation_model_metadata = 15; + * @param \Google\Cloud\AutoMl\V1\TranslationModelMetadata $var + * @return $this + */ + public function setTranslationModelMetadata($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\TranslationModelMetadata::class); + $this->writeOneof(15, $var); + + return $this; + } + + /** + * Output only. Resource name of the model. + * Format: `projects/{project_id}/locations/{location_id}/models/{model_id}` + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. Resource name of the model. + * Format: `projects/{project_id}/locations/{location_id}/models/{model_id}` + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The name of the model to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. It must start with a letter. + * + * Generated from protobuf field string display_name = 2; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * Required. The name of the model to show in the interface. The name can be + * up to 32 characters long and can consist only of ASCII Latin letters A-Z + * and a-z, underscores + * (_), and ASCII digits 0-9. It must start with a letter. + * + * Generated from protobuf field string display_name = 2; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * Required. The resource ID of the dataset used to create the model. The dataset must + * come from the same ancestor project and location. + * + * Generated from protobuf field string dataset_id = 3; + * @return string + */ + public function getDatasetId() + { + return $this->dataset_id; + } + + /** + * Required. The resource ID of the dataset used to create the model. The dataset must + * come from the same ancestor project and location. + * + * Generated from protobuf field string dataset_id = 3; + * @param string $var + * @return $this + */ + public function setDatasetId($var) + { + GPBUtil::checkString($var, True); + $this->dataset_id = $var; + + return $this; + } + + /** + * Output only. Timestamp when the model training finished and can be used for prediction. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 7; + * @return \Google\Protobuf\Timestamp + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Output only. Timestamp when the model training finished and can be used for prediction. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 7; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Timestamp when this model was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 11; + * @return \Google\Protobuf\Timestamp + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Output only. Timestamp when this model was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 11; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Output only. Deployment state of the model. A model can only serve + * prediction requests after it gets deployed. + * + * Generated from protobuf field .google.cloud.automl.v1.Model.DeploymentState deployment_state = 8; + * @return int + */ + public function getDeploymentState() + { + return $this->deployment_state; + } + + /** + * Output only. Deployment state of the model. A model can only serve + * prediction requests after it gets deployed. + * + * Generated from protobuf field .google.cloud.automl.v1.Model.DeploymentState deployment_state = 8; + * @param int $var + * @return $this + */ + public function setDeploymentState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\AutoMl\V1\Model_DeploymentState::class); + $this->deployment_state = $var; + + return $this; + } + + /** + * Optional. The labels with user-defined metadata to organize your model. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 34; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Optional. The labels with user-defined metadata to organize your model. + * Label keys and values can be no longer than 64 characters + * (Unicode codepoints), can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 34; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + + /** + * @return string + */ + public function getModelMetadata() + { + return $this->whichOneof("model_metadata"); + } + +} + diff --git a/AutoMl/src/V1/Model/DeploymentState.php b/AutoMl/src/V1/Model/DeploymentState.php new file mode 100644 index 000000000000..717194cacb0f --- /dev/null +++ b/AutoMl/src/V1/Model/DeploymentState.php @@ -0,0 +1,64 @@ +google.cloud.automl.v1.Model.DeploymentState + */ +class DeploymentState +{ + /** + * Should not be used, an un-set enum has this value by default. + * + * Generated from protobuf enum DEPLOYMENT_STATE_UNSPECIFIED = 0; + */ + const DEPLOYMENT_STATE_UNSPECIFIED = 0; + /** + * Model is deployed. + * + * Generated from protobuf enum DEPLOYED = 1; + */ + const DEPLOYED = 1; + /** + * Model is not deployed. + * + * Generated from protobuf enum UNDEPLOYED = 2; + */ + const UNDEPLOYED = 2; + + private static $valueToName = [ + self::DEPLOYMENT_STATE_UNSPECIFIED => 'DEPLOYMENT_STATE_UNSPECIFIED', + self::DEPLOYED => 'DEPLOYED', + self::UNDEPLOYED => 'UNDEPLOYED', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(DeploymentState::class, \Google\Cloud\AutoMl\V1\Model_DeploymentState::class); + diff --git a/AutoMl/src/V1/ModelEvaluation.php b/AutoMl/src/V1/ModelEvaluation.php new file mode 100644 index 000000000000..c364623f748a --- /dev/null +++ b/AutoMl/src/V1/ModelEvaluation.php @@ -0,0 +1,246 @@ +google.cloud.automl.v1.ModelEvaluation + */ +class ModelEvaluation extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Resource name of the model evaluation. + * Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}/modelEvaluations/{model_evaluation_id}` + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Output only. The ID of the annotation spec that the model evaluation applies to. The + * The ID is empty for the overall model evaluation. + * + * Generated from protobuf field string annotation_spec_id = 2; + */ + private $annotation_spec_id = ''; + /** + * Output only. Timestamp when this model evaluation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; + */ + private $create_time = null; + /** + * Output only. The number of examples used for model evaluation, i.e. for + * which ground truth from time of model creation is compared against the + * predicted annotations created by the model. + * For overall ModelEvaluation (i.e. with annotation_spec_id not set) this is + * the total number of all examples used for evaluation. + * Otherwise, this is the count of examples that according to the ground + * truth were annotated by the + * [annotation_spec_id][google.cloud.automl.v1beta1.ModelEvaluation.annotation_spec_id]. + * + * Generated from protobuf field int32 evaluated_example_count = 6; + */ + private $evaluated_example_count = 0; + protected $metrics; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\TranslationEvaluationMetrics $translation_evaluation_metrics + * Model evaluation metrics for translation. + * @type string $name + * Output only. Resource name of the model evaluation. + * Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}/modelEvaluations/{model_evaluation_id}` + * @type string $annotation_spec_id + * Output only. The ID of the annotation spec that the model evaluation applies to. The + * The ID is empty for the overall model evaluation. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Timestamp when this model evaluation was created. + * @type int $evaluated_example_count + * Output only. The number of examples used for model evaluation, i.e. for + * which ground truth from time of model creation is compared against the + * predicted annotations created by the model. + * For overall ModelEvaluation (i.e. with annotation_spec_id not set) this is + * the total number of all examples used for evaluation. + * Otherwise, this is the count of examples that according to the ground + * truth were annotated by the + * [annotation_spec_id][google.cloud.automl.v1beta1.ModelEvaluation.annotation_spec_id]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\ModelEvaluation::initOnce(); + parent::__construct($data); + } + + /** + * Model evaluation metrics for translation. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationEvaluationMetrics translation_evaluation_metrics = 9; + * @return \Google\Cloud\AutoMl\V1\TranslationEvaluationMetrics + */ + public function getTranslationEvaluationMetrics() + { + return $this->readOneof(9); + } + + /** + * Model evaluation metrics for translation. + * + * Generated from protobuf field .google.cloud.automl.v1.TranslationEvaluationMetrics translation_evaluation_metrics = 9; + * @param \Google\Cloud\AutoMl\V1\TranslationEvaluationMetrics $var + * @return $this + */ + public function setTranslationEvaluationMetrics($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\TranslationEvaluationMetrics::class); + $this->writeOneof(9, $var); + + return $this; + } + + /** + * Output only. Resource name of the model evaluation. + * Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}/modelEvaluations/{model_evaluation_id}` + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. Resource name of the model evaluation. + * Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}/modelEvaluations/{model_evaluation_id}` + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. The ID of the annotation spec that the model evaluation applies to. The + * The ID is empty for the overall model evaluation. + * + * Generated from protobuf field string annotation_spec_id = 2; + * @return string + */ + public function getAnnotationSpecId() + { + return $this->annotation_spec_id; + } + + /** + * Output only. The ID of the annotation spec that the model evaluation applies to. The + * The ID is empty for the overall model evaluation. + * + * Generated from protobuf field string annotation_spec_id = 2; + * @param string $var + * @return $this + */ + public function setAnnotationSpecId($var) + { + GPBUtil::checkString($var, True); + $this->annotation_spec_id = $var; + + return $this; + } + + /** + * Output only. Timestamp when this model evaluation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; + * @return \Google\Protobuf\Timestamp + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Output only. Timestamp when this model evaluation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The number of examples used for model evaluation, i.e. for + * which ground truth from time of model creation is compared against the + * predicted annotations created by the model. + * For overall ModelEvaluation (i.e. with annotation_spec_id not set) this is + * the total number of all examples used for evaluation. + * Otherwise, this is the count of examples that according to the ground + * truth were annotated by the + * [annotation_spec_id][google.cloud.automl.v1beta1.ModelEvaluation.annotation_spec_id]. + * + * Generated from protobuf field int32 evaluated_example_count = 6; + * @return int + */ + public function getEvaluatedExampleCount() + { + return $this->evaluated_example_count; + } + + /** + * Output only. The number of examples used for model evaluation, i.e. for + * which ground truth from time of model creation is compared against the + * predicted annotations created by the model. + * For overall ModelEvaluation (i.e. with annotation_spec_id not set) this is + * the total number of all examples used for evaluation. + * Otherwise, this is the count of examples that according to the ground + * truth were annotated by the + * [annotation_spec_id][google.cloud.automl.v1beta1.ModelEvaluation.annotation_spec_id]. + * + * Generated from protobuf field int32 evaluated_example_count = 6; + * @param int $var + * @return $this + */ + public function setEvaluatedExampleCount($var) + { + GPBUtil::checkInt32($var); + $this->evaluated_example_count = $var; + + return $this; + } + + /** + * @return string + */ + public function getMetrics() + { + return $this->whichOneof("metrics"); + } + +} + diff --git a/AutoMl/src/V1/Model_DeploymentState.php b/AutoMl/src/V1/Model_DeploymentState.php new file mode 100644 index 000000000000..14f31f24c7ea --- /dev/null +++ b/AutoMl/src/V1/Model_DeploymentState.php @@ -0,0 +1,16 @@ +google.cloud.automl.v1.OperationMetadata + */ +class OperationMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Progress of operation. Range: [0, 100]. + * Not used currently. + * + * Generated from protobuf field int32 progress_percent = 13; + */ + private $progress_percent = 0; + /** + * Output only. Partial failures encountered. + * E.g. single files that couldn't be read. + * This field should never exceed 20 entries. + * Status details field will contain standard GCP error details. + * + * Generated from protobuf field repeated .google.rpc.Status partial_failures = 2; + */ + private $partial_failures; + /** + * Output only. Time when the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3; + */ + private $create_time = null; + /** + * Output only. Time when the operation was updated for the last time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4; + */ + private $update_time = null; + protected $details; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\DeleteOperationMetadata $delete_details + * Details of a Delete operation. + * @type \Google\Cloud\AutoMl\V1\CreateModelOperationMetadata $create_model_details + * Details of CreateModel operation. + * @type int $progress_percent + * Output only. Progress of operation. Range: [0, 100]. + * Not used currently. + * @type \Google\Rpc\Status[]|\Google\Protobuf\Internal\RepeatedField $partial_failures + * Output only. Partial failures encountered. + * E.g. single files that couldn't be read. + * This field should never exceed 20 entries. + * Status details field will contain standard GCP error details. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Time when the operation was created. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Time when the operation was updated for the last time. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Operations::initOnce(); + parent::__construct($data); + } + + /** + * Details of a Delete operation. + * + * Generated from protobuf field .google.cloud.automl.v1.DeleteOperationMetadata delete_details = 8; + * @return \Google\Cloud\AutoMl\V1\DeleteOperationMetadata + */ + public function getDeleteDetails() + { + return $this->readOneof(8); + } + + /** + * Details of a Delete operation. + * + * Generated from protobuf field .google.cloud.automl.v1.DeleteOperationMetadata delete_details = 8; + * @param \Google\Cloud\AutoMl\V1\DeleteOperationMetadata $var + * @return $this + */ + public function setDeleteDetails($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\DeleteOperationMetadata::class); + $this->writeOneof(8, $var); + + return $this; + } + + /** + * Details of CreateModel operation. + * + * Generated from protobuf field .google.cloud.automl.v1.CreateModelOperationMetadata create_model_details = 10; + * @return \Google\Cloud\AutoMl\V1\CreateModelOperationMetadata + */ + public function getCreateModelDetails() + { + return $this->readOneof(10); + } + + /** + * Details of CreateModel operation. + * + * Generated from protobuf field .google.cloud.automl.v1.CreateModelOperationMetadata create_model_details = 10; + * @param \Google\Cloud\AutoMl\V1\CreateModelOperationMetadata $var + * @return $this + */ + public function setCreateModelDetails($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\CreateModelOperationMetadata::class); + $this->writeOneof(10, $var); + + return $this; + } + + /** + * Output only. Progress of operation. Range: [0, 100]. + * Not used currently. + * + * Generated from protobuf field int32 progress_percent = 13; + * @return int + */ + public function getProgressPercent() + { + return $this->progress_percent; + } + + /** + * Output only. Progress of operation. Range: [0, 100]. + * Not used currently. + * + * Generated from protobuf field int32 progress_percent = 13; + * @param int $var + * @return $this + */ + public function setProgressPercent($var) + { + GPBUtil::checkInt32($var); + $this->progress_percent = $var; + + return $this; + } + + /** + * Output only. Partial failures encountered. + * E.g. single files that couldn't be read. + * This field should never exceed 20 entries. + * Status details field will contain standard GCP error details. + * + * Generated from protobuf field repeated .google.rpc.Status partial_failures = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPartialFailures() + { + return $this->partial_failures; + } + + /** + * Output only. Partial failures encountered. + * E.g. single files that couldn't be read. + * This field should never exceed 20 entries. + * Status details field will contain standard GCP error details. + * + * Generated from protobuf field repeated .google.rpc.Status partial_failures = 2; + * @param \Google\Rpc\Status[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPartialFailures($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Rpc\Status::class); + $this->partial_failures = $arr; + + return $this; + } + + /** + * Output only. Time when the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3; + * @return \Google\Protobuf\Timestamp + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Output only. Time when the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Time when the operation was updated for the last time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4; + * @return \Google\Protobuf\Timestamp + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Output only. Time when the operation was updated for the last time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * @return string + */ + public function getDetails() + { + return $this->whichOneof("details"); + } + +} + diff --git a/AutoMl/src/V1/OutputConfig.php b/AutoMl/src/V1/OutputConfig.php new file mode 100644 index 000000000000..c1bec11c669f --- /dev/null +++ b/AutoMl/src/V1/OutputConfig.php @@ -0,0 +1,98 @@ +_` + * where will be made + * BigQuery-dataset-name compatible (e.g. most special characters will + * become underscores), and timestamp will be in + * YYYY_MM_DDThh_mm_ss_sssZ "based on ISO-8601" format. In that + * dataset a new table called `primary_table` will be created, and + * filled with precisely the same data as this obtained on import. + * + * Generated from protobuf message google.cloud.automl.v1.OutputConfig + */ +class OutputConfig extends \Google\Protobuf\Internal\Message +{ + protected $destination; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\GcsDestination $gcs_destination + * The Google Cloud Storage location where the output is to be written to. + * For Image Object Detection, Text Extraction, Video Classification and + * Tables, in the given directory a new directory will be created with name: + * export_data-- where + * timestamp is in YYYY-MM-DDThh:mm:ss.sssZ ISO-8601 format. All export + * output will be written into that directory. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Io::initOnce(); + parent::__construct($data); + } + + /** + * The Google Cloud Storage location where the output is to be written to. + * For Image Object Detection, Text Extraction, Video Classification and + * Tables, in the given directory a new directory will be created with name: + * export_data-- where + * timestamp is in YYYY-MM-DDThh:mm:ss.sssZ ISO-8601 format. All export + * output will be written into that directory. + * + * Generated from protobuf field .google.cloud.automl.v1.GcsDestination gcs_destination = 1; + * @return \Google\Cloud\AutoMl\V1\GcsDestination + */ + public function getGcsDestination() + { + return $this->readOneof(1); + } + + /** + * The Google Cloud Storage location where the output is to be written to. + * For Image Object Detection, Text Extraction, Video Classification and + * Tables, in the given directory a new directory will be created with name: + * export_data-- where + * timestamp is in YYYY-MM-DDThh:mm:ss.sssZ ISO-8601 format. All export + * output will be written into that directory. + * + * Generated from protobuf field .google.cloud.automl.v1.GcsDestination gcs_destination = 1; + * @param \Google\Cloud\AutoMl\V1\GcsDestination $var + * @return $this + */ + public function setGcsDestination($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\GcsDestination::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * @return string + */ + public function getDestination() + { + return $this->whichOneof("destination"); + } + +} + diff --git a/AutoMl/src/V1/PredictRequest.php b/AutoMl/src/V1/PredictRequest.php new file mode 100644 index 000000000000..eadb9c3afc1a --- /dev/null +++ b/AutoMl/src/V1/PredictRequest.php @@ -0,0 +1,143 @@ +google.cloud.automl.v1.PredictRequest + */ +class PredictRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Name of the model requested to serve the prediction. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Required. Payload to perform a prediction on. The payload must match the + * problem type that the model was trained to solve. + * + * Generated from protobuf field .google.cloud.automl.v1.ExamplePayload payload = 2; + */ + private $payload = null; + /** + * Additional domain-specific parameters, any string must be up to 25000 + * characters long. + * + * Generated from protobuf field map params = 3; + */ + private $params; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Name of the model requested to serve the prediction. + * @type \Google\Cloud\AutoMl\V1\ExamplePayload $payload + * Required. Payload to perform a prediction on. The payload must match the + * problem type that the model was trained to solve. + * @type array|\Google\Protobuf\Internal\MapField $params + * Additional domain-specific parameters, any string must be up to 25000 + * characters long. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\PredictionService::initOnce(); + parent::__construct($data); + } + + /** + * Name of the model requested to serve the prediction. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Name of the model requested to serve the prediction. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. Payload to perform a prediction on. The payload must match the + * problem type that the model was trained to solve. + * + * Generated from protobuf field .google.cloud.automl.v1.ExamplePayload payload = 2; + * @return \Google\Cloud\AutoMl\V1\ExamplePayload + */ + public function getPayload() + { + return $this->payload; + } + + /** + * Required. Payload to perform a prediction on. The payload must match the + * problem type that the model was trained to solve. + * + * Generated from protobuf field .google.cloud.automl.v1.ExamplePayload payload = 2; + * @param \Google\Cloud\AutoMl\V1\ExamplePayload $var + * @return $this + */ + public function setPayload($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\ExamplePayload::class); + $this->payload = $var; + + return $this; + } + + /** + * Additional domain-specific parameters, any string must be up to 25000 + * characters long. + * + * Generated from protobuf field map params = 3; + * @return \Google\Protobuf\Internal\MapField + */ + public function getParams() + { + return $this->params; + } + + /** + * Additional domain-specific parameters, any string must be up to 25000 + * characters long. + * + * Generated from protobuf field map params = 3; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setParams($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->params = $arr; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/PredictResponse.php b/AutoMl/src/V1/PredictResponse.php new file mode 100644 index 000000000000..dfdad9b88700 --- /dev/null +++ b/AutoMl/src/V1/PredictResponse.php @@ -0,0 +1,105 @@ +google.cloud.automl.v1.PredictResponse + */ +class PredictResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Prediction result. + * Translation and Text Sentiment will return precisely one payload. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.AnnotationPayload payload = 1; + */ + private $payload; + /** + * Additional domain-specific prediction response metadata. + * + * Generated from protobuf field map metadata = 2; + */ + private $metadata; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\AnnotationPayload[]|\Google\Protobuf\Internal\RepeatedField $payload + * Prediction result. + * Translation and Text Sentiment will return precisely one payload. + * @type array|\Google\Protobuf\Internal\MapField $metadata + * Additional domain-specific prediction response metadata. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\PredictionService::initOnce(); + parent::__construct($data); + } + + /** + * Prediction result. + * Translation and Text Sentiment will return precisely one payload. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.AnnotationPayload payload = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPayload() + { + return $this->payload; + } + + /** + * Prediction result. + * Translation and Text Sentiment will return precisely one payload. + * + * Generated from protobuf field repeated .google.cloud.automl.v1.AnnotationPayload payload = 1; + * @param \Google\Cloud\AutoMl\V1\AnnotationPayload[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPayload($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1\AnnotationPayload::class); + $this->payload = $arr; + + return $this; + } + + /** + * Additional domain-specific prediction response metadata. + * + * Generated from protobuf field map metadata = 2; + * @return \Google\Protobuf\Internal\MapField + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * Additional domain-specific prediction response metadata. + * + * Generated from protobuf field map metadata = 2; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setMetadata($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->metadata = $arr; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/PredictionServiceClient.php b/AutoMl/src/V1/PredictionServiceClient.php new file mode 100644 index 000000000000..d455c6bf7075 --- /dev/null +++ b/AutoMl/src/V1/PredictionServiceClient.php @@ -0,0 +1,38 @@ +_simpleRequest('/google.cloud.automl.v1.PredictionService/Predict', + $argument, + ['\Google\Cloud\AutoMl\V1\PredictResponse', 'decode'], + $metadata, $options); + } + +} diff --git a/AutoMl/src/V1/TextSnippet.php b/AutoMl/src/V1/TextSnippet.php new file mode 100644 index 000000000000..c178be0b8aa2 --- /dev/null +++ b/AutoMl/src/V1/TextSnippet.php @@ -0,0 +1,147 @@ +google.cloud.automl.v1.TextSnippet + */ +class TextSnippet extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The content of the text snippet as a string. Up to 250000 + * characters long. + * + * Generated from protobuf field string content = 1; + */ + private $content = ''; + /** + * Optional. The format of [content][google.cloud.automl.v1.TextSnippet.content]. Currently the only two allowed + * values are "text/html" and "text/plain". If left blank, the format is + * automatically determined from the type of the uploaded [content][google.cloud.automl.v1.TextSnippet.content]. + * + * Generated from protobuf field string mime_type = 2; + */ + private $mime_type = ''; + /** + * Output only. HTTP URI where you can download the content. + * + * Generated from protobuf field string content_uri = 4; + */ + private $content_uri = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $content + * Required. The content of the text snippet as a string. Up to 250000 + * characters long. + * @type string $mime_type + * Optional. The format of [content][google.cloud.automl.v1.TextSnippet.content]. Currently the only two allowed + * values are "text/html" and "text/plain". If left blank, the format is + * automatically determined from the type of the uploaded [content][google.cloud.automl.v1.TextSnippet.content]. + * @type string $content_uri + * Output only. HTTP URI where you can download the content. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\DataItems::initOnce(); + parent::__construct($data); + } + + /** + * Required. The content of the text snippet as a string. Up to 250000 + * characters long. + * + * Generated from protobuf field string content = 1; + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Required. The content of the text snippet as a string. Up to 250000 + * characters long. + * + * Generated from protobuf field string content = 1; + * @param string $var + * @return $this + */ + public function setContent($var) + { + GPBUtil::checkString($var, True); + $this->content = $var; + + return $this; + } + + /** + * Optional. The format of [content][google.cloud.automl.v1.TextSnippet.content]. Currently the only two allowed + * values are "text/html" and "text/plain". If left blank, the format is + * automatically determined from the type of the uploaded [content][google.cloud.automl.v1.TextSnippet.content]. + * + * Generated from protobuf field string mime_type = 2; + * @return string + */ + public function getMimeType() + { + return $this->mime_type; + } + + /** + * Optional. The format of [content][google.cloud.automl.v1.TextSnippet.content]. Currently the only two allowed + * values are "text/html" and "text/plain". If left blank, the format is + * automatically determined from the type of the uploaded [content][google.cloud.automl.v1.TextSnippet.content]. + * + * Generated from protobuf field string mime_type = 2; + * @param string $var + * @return $this + */ + public function setMimeType($var) + { + GPBUtil::checkString($var, True); + $this->mime_type = $var; + + return $this; + } + + /** + * Output only. HTTP URI where you can download the content. + * + * Generated from protobuf field string content_uri = 4; + * @return string + */ + public function getContentUri() + { + return $this->content_uri; + } + + /** + * Output only. HTTP URI where you can download the content. + * + * Generated from protobuf field string content_uri = 4; + * @param string $var + * @return $this + */ + public function setContentUri($var) + { + GPBUtil::checkString($var, True); + $this->content_uri = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/TranslationAnnotation.php b/AutoMl/src/V1/TranslationAnnotation.php new file mode 100644 index 000000000000..6e0f78e58b1d --- /dev/null +++ b/AutoMl/src/V1/TranslationAnnotation.php @@ -0,0 +1,67 @@ +google.cloud.automl.v1.TranslationAnnotation + */ +class TranslationAnnotation extends \Google\Protobuf\Internal\Message +{ + /** + * Output only . The translated content. + * + * Generated from protobuf field .google.cloud.automl.v1.TextSnippet translated_content = 1; + */ + private $translated_content = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\TextSnippet $translated_content + * Output only . The translated content. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Translation::initOnce(); + parent::__construct($data); + } + + /** + * Output only . The translated content. + * + * Generated from protobuf field .google.cloud.automl.v1.TextSnippet translated_content = 1; + * @return \Google\Cloud\AutoMl\V1\TextSnippet + */ + public function getTranslatedContent() + { + return $this->translated_content; + } + + /** + * Output only . The translated content. + * + * Generated from protobuf field .google.cloud.automl.v1.TextSnippet translated_content = 1; + * @param \Google\Cloud\AutoMl\V1\TextSnippet $var + * @return $this + */ + public function setTranslatedContent($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\TextSnippet::class); + $this->translated_content = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/TranslationDatasetMetadata.php b/AutoMl/src/V1/TranslationDatasetMetadata.php new file mode 100644 index 000000000000..21217b05db10 --- /dev/null +++ b/AutoMl/src/V1/TranslationDatasetMetadata.php @@ -0,0 +1,101 @@ +google.cloud.automl.v1.TranslationDatasetMetadata + */ +class TranslationDatasetMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The BCP-47 language code of the source language. + * + * Generated from protobuf field string source_language_code = 1; + */ + private $source_language_code = ''; + /** + * Required. The BCP-47 language code of the target language. + * + * Generated from protobuf field string target_language_code = 2; + */ + private $target_language_code = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $source_language_code + * Required. The BCP-47 language code of the source language. + * @type string $target_language_code + * Required. The BCP-47 language code of the target language. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Translation::initOnce(); + parent::__construct($data); + } + + /** + * Required. The BCP-47 language code of the source language. + * + * Generated from protobuf field string source_language_code = 1; + * @return string + */ + public function getSourceLanguageCode() + { + return $this->source_language_code; + } + + /** + * Required. The BCP-47 language code of the source language. + * + * Generated from protobuf field string source_language_code = 1; + * @param string $var + * @return $this + */ + public function setSourceLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->source_language_code = $var; + + return $this; + } + + /** + * Required. The BCP-47 language code of the target language. + * + * Generated from protobuf field string target_language_code = 2; + * @return string + */ + public function getTargetLanguageCode() + { + return $this->target_language_code; + } + + /** + * Required. The BCP-47 language code of the target language. + * + * Generated from protobuf field string target_language_code = 2; + * @param string $var + * @return $this + */ + public function setTargetLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->target_language_code = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/TranslationEvaluationMetrics.php b/AutoMl/src/V1/TranslationEvaluationMetrics.php new file mode 100644 index 000000000000..9c3d2dd2f43d --- /dev/null +++ b/AutoMl/src/V1/TranslationEvaluationMetrics.php @@ -0,0 +1,101 @@ +google.cloud.automl.v1.TranslationEvaluationMetrics + */ +class TranslationEvaluationMetrics extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. BLEU score. + * + * Generated from protobuf field double bleu_score = 1; + */ + private $bleu_score = 0.0; + /** + * Output only. BLEU score for base model. + * + * Generated from protobuf field double base_bleu_score = 2; + */ + private $base_bleu_score = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type float $bleu_score + * Output only. BLEU score. + * @type float $base_bleu_score + * Output only. BLEU score for base model. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Translation::initOnce(); + parent::__construct($data); + } + + /** + * Output only. BLEU score. + * + * Generated from protobuf field double bleu_score = 1; + * @return float + */ + public function getBleuScore() + { + return $this->bleu_score; + } + + /** + * Output only. BLEU score. + * + * Generated from protobuf field double bleu_score = 1; + * @param float $var + * @return $this + */ + public function setBleuScore($var) + { + GPBUtil::checkDouble($var); + $this->bleu_score = $var; + + return $this; + } + + /** + * Output only. BLEU score for base model. + * + * Generated from protobuf field double base_bleu_score = 2; + * @return float + */ + public function getBaseBleuScore() + { + return $this->base_bleu_score; + } + + /** + * Output only. BLEU score for base model. + * + * Generated from protobuf field double base_bleu_score = 2; + * @param float $var + * @return $this + */ + public function setBaseBleuScore($var) + { + GPBUtil::checkDouble($var); + $this->base_bleu_score = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/TranslationModelMetadata.php b/AutoMl/src/V1/TranslationModelMetadata.php new file mode 100644 index 000000000000..589f9f7cc460 --- /dev/null +++ b/AutoMl/src/V1/TranslationModelMetadata.php @@ -0,0 +1,155 @@ +google.cloud.automl.v1.TranslationModelMetadata + */ +class TranslationModelMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the model to use as a baseline to train the custom + * model. If unset, we use the default base model provided by Google + * Translate. Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}` + * + * Generated from protobuf field string base_model = 1; + */ + private $base_model = ''; + /** + * Output only. Inferred from the dataset. + * The source languge (The BCP-47 language code) that is used for training. + * + * Generated from protobuf field string source_language_code = 2; + */ + private $source_language_code = ''; + /** + * Output only. The target languge (The BCP-47 language code) that is used for + * training. + * + * Generated from protobuf field string target_language_code = 3; + */ + private $target_language_code = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $base_model + * The resource name of the model to use as a baseline to train the custom + * model. If unset, we use the default base model provided by Google + * Translate. Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}` + * @type string $source_language_code + * Output only. Inferred from the dataset. + * The source languge (The BCP-47 language code) that is used for training. + * @type string $target_language_code + * Output only. The target languge (The BCP-47 language code) that is used for + * training. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Translation::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the model to use as a baseline to train the custom + * model. If unset, we use the default base model provided by Google + * Translate. Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}` + * + * Generated from protobuf field string base_model = 1; + * @return string + */ + public function getBaseModel() + { + return $this->base_model; + } + + /** + * The resource name of the model to use as a baseline to train the custom + * model. If unset, we use the default base model provided by Google + * Translate. Format: + * `projects/{project_id}/locations/{location_id}/models/{model_id}` + * + * Generated from protobuf field string base_model = 1; + * @param string $var + * @return $this + */ + public function setBaseModel($var) + { + GPBUtil::checkString($var, True); + $this->base_model = $var; + + return $this; + } + + /** + * Output only. Inferred from the dataset. + * The source languge (The BCP-47 language code) that is used for training. + * + * Generated from protobuf field string source_language_code = 2; + * @return string + */ + public function getSourceLanguageCode() + { + return $this->source_language_code; + } + + /** + * Output only. Inferred from the dataset. + * The source languge (The BCP-47 language code) that is used for training. + * + * Generated from protobuf field string source_language_code = 2; + * @param string $var + * @return $this + */ + public function setSourceLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->source_language_code = $var; + + return $this; + } + + /** + * Output only. The target languge (The BCP-47 language code) that is used for + * training. + * + * Generated from protobuf field string target_language_code = 3; + * @return string + */ + public function getTargetLanguageCode() + { + return $this->target_language_code; + } + + /** + * Output only. The target languge (The BCP-47 language code) that is used for + * training. + * + * Generated from protobuf field string target_language_code = 3; + * @param string $var + * @return $this + */ + public function setTargetLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->target_language_code = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/UpdateDatasetRequest.php b/AutoMl/src/V1/UpdateDatasetRequest.php new file mode 100644 index 000000000000..919efd928633 --- /dev/null +++ b/AutoMl/src/V1/UpdateDatasetRequest.php @@ -0,0 +1,101 @@ +google.cloud.automl.v1.UpdateDatasetRequest + */ +class UpdateDatasetRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The dataset which replaces the resource on the server. + * + * Generated from protobuf field .google.cloud.automl.v1.Dataset dataset = 1; + */ + private $dataset = null; + /** + * Required. The update mask applies to the resource. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + */ + private $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\Dataset $dataset + * The dataset which replaces the resource on the server. + * @type \Google\Protobuf\FieldMask $update_mask + * Required. The update mask applies to the resource. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The dataset which replaces the resource on the server. + * + * Generated from protobuf field .google.cloud.automl.v1.Dataset dataset = 1; + * @return \Google\Cloud\AutoMl\V1\Dataset + */ + public function getDataset() + { + return $this->dataset; + } + + /** + * The dataset which replaces the resource on the server. + * + * Generated from protobuf field .google.cloud.automl.v1.Dataset dataset = 1; + * @param \Google\Cloud\AutoMl\V1\Dataset $var + * @return $this + */ + public function setDataset($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\Dataset::class); + $this->dataset = $var; + + return $this; + } + + /** + * Required. The update mask applies to the resource. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @return \Google\Protobuf\FieldMask + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + /** + * Required. The update mask applies to the resource. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/UpdateModelRequest.php b/AutoMl/src/V1/UpdateModelRequest.php new file mode 100644 index 000000000000..08bfbc764513 --- /dev/null +++ b/AutoMl/src/V1/UpdateModelRequest.php @@ -0,0 +1,101 @@ +google.cloud.automl.v1.UpdateModelRequest + */ +class UpdateModelRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The model which replaces the resource on the server. + * + * Generated from protobuf field .google.cloud.automl.v1.Model model = 1; + */ + private $model = null; + /** + * Required. The update mask applies to the resource. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + */ + private $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\AutoMl\V1\Model $model + * The model which replaces the resource on the server. + * @type \Google\Protobuf\FieldMask $update_mask + * Required. The update mask applies to the resource. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Automl\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The model which replaces the resource on the server. + * + * Generated from protobuf field .google.cloud.automl.v1.Model model = 1; + * @return \Google\Cloud\AutoMl\V1\Model + */ + public function getModel() + { + return $this->model; + } + + /** + * The model which replaces the resource on the server. + * + * Generated from protobuf field .google.cloud.automl.v1.Model model = 1; + * @param \Google\Cloud\AutoMl\V1\Model $var + * @return $this + */ + public function setModel($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1\Model::class); + $this->model = $var; + + return $this; + } + + /** + * Required. The update mask applies to the resource. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @return \Google\Protobuf\FieldMask + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + /** + * Required. The update mask applies to the resource. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/AutoMl/src/V1/resources/auto_ml_client_config.json b/AutoMl/src/V1/resources/auto_ml_client_config.json new file mode 100644 index 000000000000..09e36c155d29 --- /dev/null +++ b/AutoMl/src/V1/resources/auto_ml_client_config.json @@ -0,0 +1,96 @@ +{ + "interfaces": { + "google.cloud.automl.v1.AutoMl": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateDataset": { + "timeout_millis": 5000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateDataset": { + "timeout_millis": 5000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDataset": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListDatasets": { + "timeout_millis": 50000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteDataset": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportData": { + "timeout_millis": 20000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ExportData": { + "timeout_millis": 5000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateModel": { + "timeout_millis": 20000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetModel": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateModel": { + "timeout_millis": 5000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListModels": { + "timeout_millis": 50000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteModel": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetModelEvaluation": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListModelEvaluations": { + "timeout_millis": 50000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/AutoMl/src/V1/resources/auto_ml_descriptor_config.php b/AutoMl/src/V1/resources/auto_ml_descriptor_config.php new file mode 100644 index 000000000000..2e11ff8dbc4a --- /dev/null +++ b/AutoMl/src/V1/resources/auto_ml_descriptor_config.php @@ -0,0 +1,88 @@ + [ + 'google.cloud.automl.v1.AutoMl' => [ + 'DeleteDataset' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\AutoMl\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'ImportData' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\AutoMl\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '3600000', + ], + ], + 'ExportData' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\AutoMl\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'CreateModel' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\AutoMl\V1\Model', + 'metadataReturnType' => '\Google\Cloud\AutoMl\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'DeleteModel' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\AutoMl\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'ListDatasets' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDatasets', + ], + ], + 'ListModels' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getModel', + ], + ], + 'ListModelEvaluations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getModelEvaluation', + ], + ], + ], + ], +]; diff --git a/AutoMl/src/V1/resources/auto_ml_rest_client_config.php b/AutoMl/src/V1/resources/auto_ml_rest_client_config.php new file mode 100644 index 000000000000..dfa6989178b7 --- /dev/null +++ b/AutoMl/src/V1/resources/auto_ml_rest_client_config.php @@ -0,0 +1,267 @@ + [ + 'google.cloud.automl.v1.AutoMl' => [ + 'CreateDataset' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/datasets', + 'body' => 'dataset', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateDataset' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{dataset.name=projects/*/locations/*/datasets/*}', + 'body' => 'dataset', + 'placeholders' => [ + 'dataset.name' => [ + 'getters' => [ + 'getDataset', + 'getName', + ], + ], + ], + ], + 'GetDataset' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListDatasets' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/datasets', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteDataset' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ImportData' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*}:importData', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ExportData' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*}:exportData', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CreateModel' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/models', + 'body' => 'model', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'GetModel' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/models/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'UpdateModel' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{model.name=projects/*/locations/*/models/*}', + 'body' => 'model', + 'placeholders' => [ + 'model.name' => [ + 'getters' => [ + 'getModel', + 'getName', + ], + ], + ], + ], + 'ListModels' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/models', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteModel' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/models/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetModelEvaluation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/models/*/modelEvaluations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListModelEvaluations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*/models/*}/modelEvaluations', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + ], + 'google.iam.v1.IAMPolicy' => [ + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/datasets/*}:setIamPolicy', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/models/*}:setIamPolicy', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/datasets/*}:getIamPolicy', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/models/*}:getIamPolicy', + ], + ], + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/**}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*}/operations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], +]; diff --git a/AutoMl/src/V1/resources/prediction_service_client_config.json b/AutoMl/src/V1/resources/prediction_service_client_config.json new file mode 100644 index 000000000000..0786331ff908 --- /dev/null +++ b/AutoMl/src/V1/resources/prediction_service_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.automl.v1.PredictionService": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/AutoMl/src/V1/resources/prediction_service_descriptor_config.php b/AutoMl/src/V1/resources/prediction_service_descriptor_config.php new file mode 100644 index 000000000000..2ec0e8411ef7 --- /dev/null +++ b/AutoMl/src/V1/resources/prediction_service_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.cloud.automl.v1.PredictionService' => [ + ], + ], +]; diff --git a/AutoMl/src/V1/resources/prediction_service_rest_client_config.php b/AutoMl/src/V1/resources/prediction_service_rest_client_config.php new file mode 100644 index 000000000000..01b21172f691 --- /dev/null +++ b/AutoMl/src/V1/resources/prediction_service_rest_client_config.php @@ -0,0 +1,117 @@ + [ + 'google.cloud.automl.v1.PredictionService' => [ + 'Predict' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/models/*}:predict', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + 'google.iam.v1.IAMPolicy' => [ + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/datasets/*}:setIamPolicy', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/models/*}:setIamPolicy', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/datasets/*}:getIamPolicy', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/models/*}:getIamPolicy', + ], + ], + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/**}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*}/operations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], +]; diff --git a/AutoMl/synth.metadata b/AutoMl/synth.metadata index 627feaabece2..2f5cc2752ae4 100644 --- a/AutoMl/synth.metadata +++ b/AutoMl/synth.metadata @@ -1,19 +1,11 @@ { - "updateTime": "2019-09-24T09:58:37.390085Z", + "updateTime": "2019-10-04T21:45:38.831473Z", "sources": [ { "generator": { "name": "artman", - "version": "0.37.0", - "dockerImage": "googleapis/artman@sha256:0f66008f69061ea6d41499e2a34da3fc64fc7c9798077e3a37158653a135d801" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "cc332bd19c2dd9640b025e5693e83a1b428d5dff", - "internalRef": "270834186" + "version": "0.38.0", + "dockerImage": "googleapis/artman@sha256:0d2f8d429110aeb8d82df6550ef4ede59d40df9062d260a1580fce688b0512bf" } } ], @@ -27,6 +19,16 @@ "generator": "gapic", "config": "google/cloud/automl/artman_automl_v1beta1.yaml" } + }, + { + "client": { + "source": "googleapis", + "apiName": "automl", + "apiVersion": "v1", + "language": "php", + "generator": "gapic", + "config": "google/cloud/automl/artman_automl_v1.yaml" + } } ] } \ No newline at end of file diff --git a/AutoMl/synth.py b/AutoMl/synth.py index b677fa5ecd23..9fb72e7ceac3 100644 --- a/AutoMl/synth.py +++ b/AutoMl/synth.py @@ -22,23 +22,25 @@ logging.basicConfig(level=logging.DEBUG) gapic = gcp.GAPICGenerator() -common = gcp.CommonTemplates() +versions = ["V1beta1", "V1"] -library = gapic.php_library( - service='automl', - version='v1beta1', - config_path='/google/cloud/automl/artman_automl_v1beta1.yaml', - artman_output_name='google-cloud-automl-v1beta1') +for version in versions: + lower_version = version.lower() + library = gapic.php_library( + service='automl', + version=lower_version, + config_path=f'artman_automl_{lower_version}.yaml', + artman_output_name=f'google-cloud-automl-{lower_version}') -# copy all src including partial veneer classes -s.move(library / 'src') + # copy all src including partial veneer classes + s.move(library / 'src') -# copy proto files to src also -s.move(library / 'proto/src/Google/Cloud/AutoMl', 'src/') -s.move(library / 'tests/') + # copy proto files to src also + s.move(library / 'proto/src/Google/Cloud/AutoMl', 'src/') + s.move(library / 'tests/') -# copy GPBMetadata file to metadata -s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Automl', 'metadata/') + # copy GPBMetadata file to metadata + s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Automl', 'metadata/') # document and utilize apiEndpoint instead of serviceAddress s.replace( @@ -80,9 +82,19 @@ 'tests/**/V1beta1/*Test.php', r'Copyright \d{4}', r'Copyright 2019') +s.replace( + 'tests/**/V1/*Test.php', + r'Copyright \d{4}', + r'Copyright 2019') + +# temporary namespace fix for V1 +s.replace( + '**/V1/**/*.php', + r'Google\\Cloud\\AutoML\\V1', + r'Google\\Cloud\\AutoMl\\V1') # Fix class references in gapic samples -for version in ['V1beta1']: +for version in versions: pathExprs = [ 'src/' + version + '/Gapic/AutoMlGapicClient.php', 'src/' + version + '/Gapic/PredictionServiceGapicClient.php' diff --git a/AutoMl/tests/System/V1/AutoMlSmokeTest.php b/AutoMl/tests/System/V1/AutoMlSmokeTest.php new file mode 100644 index 000000000000..825602cbe45d --- /dev/null +++ b/AutoMl/tests/System/V1/AutoMlSmokeTest.php @@ -0,0 +1,94 @@ + $keyFilePath, + 'transport' => 'grpc' + ]), + ], [ + new AutoMlClient([ + 'credentials' => $keyFilePath, + 'transport' => 'rest' + ]), + ] + ]; + + self::$projectId = $keyFileData['project_id']; + + self::$hasSetUp = true; + } + + /** + * @dataProvider clientsProvider + */ + public function testAutoMl(AutoMlClient $automl) + { + $formattedParent = $automl->locationName(self::$projectId, self::$location); + $dataset = new Dataset([ + 'display_name' => uniqid(self::TESTING_PREFIX), + 'translation_dataset_metadata' => new TranslationDatasetMetadata([ + 'source_language_code' => 'en', + 'target_language_code' => 'es' + ]) + ]); + + $response = $automl->createDataset($formattedParent, $dataset); + $datasetName = $response->getName(); + $ds = $automl->getDataset($datasetName); + $this->assertInstanceOf(Dataset::class, $ds); + + // cleanup + $automl->deleteDataset($datasetName); + } + + public function clientsProvider() + { + self::setUpBeforeClass(); + return self::$clients; + } +} diff --git a/AutoMl/tests/Unit/V1/AutoMlClientTest.php b/AutoMl/tests/Unit/V1/AutoMlClientTest.php new file mode 100644 index 000000000000..71838dbe2d04 --- /dev/null +++ b/AutoMl/tests/Unit/V1/AutoMlClientTest.php @@ -0,0 +1,1528 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @return AutoMlClient + */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + + return new AutoMlClient($options); + } + + /** + * @test + */ + public function createDatasetTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name = 'name3373707'; + $done = true; + $expectedResponse = new Operation(); + $expectedResponse->setName($name); + $expectedResponse->setDone($done); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + $dataset = new Dataset(); + + $response = $client->createDataset($formattedParent, $dataset); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/CreateDataset', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getDataset(); + + $this->assertProtobufEquals($dataset, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function createDatasetExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + $dataset = new Dataset(); + + try { + $client->createDataset($formattedParent, $dataset); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function updateDatasetTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $exampleCount = 1517063674; + $etag = 'etag3123477'; + $expectedResponse = new Dataset(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); + $expectedResponse->setExampleCount($exampleCount); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + + // Mock request + $dataset = new Dataset(); + $updateMask = new FieldMask(); + + $response = $client->updateDataset($dataset, $updateMask); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/UpdateDataset', $actualFuncCall); + + $actualValue = $actualRequestObject->getDataset(); + + $this->assertProtobufEquals($dataset, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + + $this->assertProtobufEquals($updateMask, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function updateDatasetExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $dataset = new Dataset(); + $updateMask = new FieldMask(); + + try { + $client->updateDataset($dataset, $updateMask); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getDatasetTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $exampleCount = 1517063674; + $etag = 'etag3123477'; + $expectedResponse = new Dataset(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); + $expectedResponse->setExampleCount($exampleCount); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + + $response = $client->getDataset($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/GetDataset', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getDatasetExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + + try { + $client->getDataset($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listDatasetsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $nextPageToken = ''; + $datasetsElement = new Dataset(); + $datasets = [$datasetsElement]; + $expectedResponse = new ListDatasetsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDatasets($datasets); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + + $response = $client->listDatasets($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDatasets()[0], $resources[0]); + + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/ListDatasets', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listDatasetsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + + try { + $client->listDatasets($formattedParent); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function deleteDatasetTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteDatasetTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteDatasetTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + + $response = $client->deleteDataset($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/DeleteDataset', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDatasetTest'); + + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function deleteDatasetExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteDatasetTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + + $response = $client->deleteDataset($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDatasetTest'); + + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function importDataTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/importDataTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/importDataTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $inputConfig = new InputConfig(); + + $response = $client->importData($formattedName, $inputConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/ImportData', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualApiRequestObject->getInputConfig(); + + $this->assertProtobufEquals($inputConfig, $actualValue); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/importDataTest'); + + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function importDataExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/importDataTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $inputConfig = new InputConfig(); + + $response = $client->importData($formattedName, $inputConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/importDataTest'); + + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function exportDataTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/exportDataTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/exportDataTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $outputConfig = new OutputConfig(); + + $response = $client->exportData($formattedName, $outputConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/ExportData', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualApiRequestObject->getOutputConfig(); + + $this->assertProtobufEquals($outputConfig, $actualValue); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/exportDataTest'); + + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function exportDataExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/exportDataTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + + // Mock request + $formattedName = $client->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $outputConfig = new OutputConfig(); + + $response = $client->exportData($formattedName, $outputConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/exportDataTest'); + + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function createModelTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createModelTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $datasetId = 'datasetId-2115646910'; + $expectedResponse = new Model(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDatasetId($datasetId); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createModelTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + $model = new Model(); + + $response = $client->createModel($formattedParent, $model); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/CreateModel', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getModel(); + + $this->assertProtobufEquals($model, $actualValue); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createModelTest'); + + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function createModelExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createModelTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + $model = new Model(); + + $response = $client->createModel($formattedParent, $model); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createModelTest'); + + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function getModelTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $datasetId = 'datasetId-2115646910'; + $expectedResponse = new Model(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDatasetId($datasetId); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + + $response = $client->getModel($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/GetModel', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getModelExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedName = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + + try { + $client->getModel($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function updateModelTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $datasetId = 'datasetId-2115646910'; + $expectedResponse = new Model(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDatasetId($datasetId); + $transport->addResponse($expectedResponse); + + // Mock request + $model = new Model(); + $updateMask = new FieldMask(); + + $response = $client->updateModel($model, $updateMask); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/UpdateModel', $actualFuncCall); + + $actualValue = $actualRequestObject->getModel(); + + $this->assertProtobufEquals($model, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + + $this->assertProtobufEquals($updateMask, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function updateModelExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $model = new Model(); + $updateMask = new FieldMask(); + + try { + $client->updateModel($model, $updateMask); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listModelsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $nextPageToken = ''; + $modelElement = new Model(); + $model = [$modelElement]; + $expectedResponse = new ListModelsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setModel($model); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + + $response = $client->listModels($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getModel()[0], $resources[0]); + + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/ListModels', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listModelsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + + try { + $client->listModels($formattedParent); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function deleteModelTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteModelTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteModelTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + + // Mock request + $formattedName = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + + $response = $client->deleteModel($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/DeleteModel', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteModelTest'); + + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function deleteModelExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteModelTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + + // Mock request + $formattedName = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + + $response = $client->deleteModel($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteModelTest'); + + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** + * @test + */ + public function getModelEvaluationTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $annotationSpecId = 'annotationSpecId60690191'; + $evaluatedExampleCount = 277565350; + $expectedResponse = new ModelEvaluation(); + $expectedResponse->setName($name2); + $expectedResponse->setAnnotationSpecId($annotationSpecId); + $expectedResponse->setEvaluatedExampleCount($evaluatedExampleCount); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->modelEvaluationName('[PROJECT]', '[LOCATION]', '[MODEL]', '[MODEL_EVALUATION]'); + + $response = $client->getModelEvaluation($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/GetModelEvaluation', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getModelEvaluationExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedName = $client->modelEvaluationName('[PROJECT]', '[LOCATION]', '[MODEL]', '[MODEL_EVALUATION]'); + + try { + $client->getModelEvaluation($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listModelEvaluationsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $nextPageToken = ''; + $modelEvaluationElement = new ModelEvaluation(); + $modelEvaluation = [$modelEvaluationElement]; + $expectedResponse = new ListModelEvaluationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setModelEvaluation($modelEvaluation); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + $filter = 'filter-1274492040'; + + $response = $client->listModelEvaluations($formattedParent, $filter); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getModelEvaluation()[0], $resources[0]); + + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.AutoMl/ListModelEvaluations', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getFilter(); + + $this->assertProtobufEquals($filter, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listModelEvaluationsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedParent = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + $filter = 'filter-1274492040'; + + try { + $client->listModelEvaluations($formattedParent, $filter); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/AutoMl/tests/Unit/V1/PredictionServiceClientTest.php b/AutoMl/tests/Unit/V1/PredictionServiceClientTest.php new file mode 100644 index 000000000000..f36b19f82cc4 --- /dev/null +++ b/AutoMl/tests/Unit/V1/PredictionServiceClientTest.php @@ -0,0 +1,147 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @return PredictionServiceClient + */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + + return new PredictionServiceClient($options); + } + + /** + * @test + */ + public function predictTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $expectedResponse = new PredictResponse(); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + $payload = new ExamplePayload(); + + $response = $client->predict($formattedName, $payload); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.automl.v1.PredictionService/Predict', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getPayload(); + + $this->assertProtobufEquals($payload, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function predictExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $formattedName = $client->modelName('[PROJECT]', '[LOCATION]', '[MODEL]'); + $payload = new ExamplePayload(); + + try { + $client->predict($formattedName, $payload); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/README.md b/README.md index 289e0a107540..ac3701790667 100644 --- a/README.md +++ b/README.md @@ -725,8 +725,8 @@ $ composer require google/cloud-logging ```php require 'vendor/autoload.php'; -use Google\Cloud\AutoMl\V1beta1\AutoMlClient; -use Google\Cloud\AutoMl\V1beta1\TranslationDatasetMetadata; +use Google\Cloud\AutoMl\V1\AutoMlClient; +use Google\Cloud\AutoMl\V1\TranslationDatasetMetadata; $autoMlClient = new AutoMlClient(); $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]'); diff --git a/docs/contents/cloud-automl.json b/docs/contents/cloud-automl.json index 345ec7f2a53c..f6db18b7afff 100644 --- a/docs/contents/cloud-automl.json +++ b/docs/contents/cloud-automl.json @@ -22,6 +22,23 @@ "patterns": [ "automl\/v1beta1\/\\w{1,}" ] + }, + { + "title": "v1", + "type": "automl\/v1\/readme", + "nav": [ + { + "title": "AutoMlClient", + "type": "automl\/v1\/automlclient" + }, + { + "title": "PredictionServiceClient", + "type": "automl\/v1\/predictionserviceclient" + } + ], + "patterns": [ + "automl\/v1\/\\w{1,}" + ] } ], "pattern": "automl\/\\w{1,}"