Skip to content

Commit

Permalink
docs: Fix AutoMl Examples (#2233)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpedrie authored Aug 7, 2019
1 parent 1db3c9d commit bb41559
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 38 deletions.
64 changes: 32 additions & 32 deletions AutoMl/src/V1beta1/Gapic/AutoMlGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@
* calls that map to API methods. Sample code to get started:
*
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]');
* $dataset = new Dataset();
* $dataset = new Google\Cloud\AutoMl\V1beta1\Dataset();
* $response = $autoMlClient->createDataset($formattedParent, $dataset);
* } finally {
* $autoMlClient->close();
Expand Down Expand Up @@ -554,10 +554,10 @@ public function __construct(array $options = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]');
* $dataset = new Dataset();
* $dataset = new Google\Cloud\AutoMl\V1beta1\Dataset();
* $response = $autoMlClient->createDataset($formattedParent, $dataset);
* } finally {
* $autoMlClient->close();
Expand Down Expand Up @@ -607,9 +607,9 @@ public function createDataset($parent, $dataset, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $dataset = new Dataset();
* $dataset = new Google\Cloud\AutoMl\V1beta1\Dataset();
* $response = $autoMlClient->updateDataset($dataset);
* } finally {
* $autoMlClient->close();
Expand Down Expand Up @@ -667,7 +667,7 @@ public function updateDataset($dataset, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
* $response = $autoMlClient->getDataset($formattedName);
Expand Down Expand Up @@ -717,7 +717,7 @@ public function getDataset($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]');
* // Iterate over pages of elements
Expand Down Expand Up @@ -812,7 +812,7 @@ public function listDatasets($parent, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
* $operationResponse = $autoMlClient->deleteDataset($formattedName);
Expand Down Expand Up @@ -896,7 +896,7 @@ public function deleteDataset($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
* $inputConfig = new InputConfig();
Expand Down Expand Up @@ -979,7 +979,7 @@ public function importData($name, $inputConfig, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
* $outputConfig = new OutputConfig();
Expand Down Expand Up @@ -1062,7 +1062,7 @@ public function exportData($name, $outputConfig, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]');
* $model = new Model();
Expand Down Expand Up @@ -1143,7 +1143,7 @@ public function createModel($parent, $model, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $response = $autoMlClient->getModel($formattedName);
Expand Down Expand Up @@ -1193,7 +1193,7 @@ public function getModel($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]');
* // Iterate over pages of elements
Expand Down Expand Up @@ -1290,7 +1290,7 @@ public function listModels($parent, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $operationResponse = $autoMlClient->deleteModel($formattedName);
Expand Down Expand Up @@ -1377,7 +1377,7 @@ public function deleteModel($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $operationResponse = $autoMlClient->deployModel($formattedName);
Expand Down Expand Up @@ -1464,7 +1464,7 @@ public function deployModel($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $operationResponse = $autoMlClient->undeployModel($formattedName);
Expand Down Expand Up @@ -1540,7 +1540,7 @@ public function undeployModel($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->modelEvaluationName('[PROJECT]', '[LOCATION]', '[MODEL]', '[MODEL_EVALUATION]');
* $response = $autoMlClient->getModelEvaluation($formattedName);
Expand Down Expand Up @@ -1597,10 +1597,10 @@ public function getModelEvaluation($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $outputConfig = new ModelExportOutputConfig();
* $outputConfig = new Google\Cloud\AutoMl\V1beta1\ModelExportOutputConfig();
* $operationResponse = $autoMlClient->exportModel($formattedName, $outputConfig);
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
Expand Down Expand Up @@ -1689,10 +1689,10 @@ public function exportModel($name, $outputConfig, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $outputConfig = new ExportEvaluatedExamplesOutputConfig();
* $outputConfig = new Google\Cloud\AutoMl\V1beta1\ExportEvaluatedExamplesOutputConfig();
* $operationResponse = $autoMlClient->exportEvaluatedExamples($formattedName, $outputConfig);
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
Expand Down Expand Up @@ -1769,7 +1769,7 @@ public function exportEvaluatedExamples($name, $outputConfig, array $optionalArg
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* // Iterate over pages of elements
Expand Down Expand Up @@ -1866,7 +1866,7 @@ public function listModelEvaluations($parent, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->annotationSpecName('[PROJECT]', '[LOCATION]', '[DATASET]', '[ANNOTATION_SPEC]');
* $response = $autoMlClient->getAnnotationSpec($formattedName);
Expand Down Expand Up @@ -1916,7 +1916,7 @@ public function getAnnotationSpec($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->tableSpecName('[PROJECT]', '[LOCATION]', '[DATASET]', '[TABLE_SPEC]');
* $response = $autoMlClient->getTableSpec($formattedName);
Expand Down Expand Up @@ -1971,7 +1971,7 @@ public function getTableSpec($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
* // Iterate over pages of elements
Expand Down Expand Up @@ -2061,9 +2061,9 @@ public function listTableSpecs($parent, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $tableSpec = new TableSpec();
* $tableSpec = new Google\Cloud\AutoMl\V1beta1\TableSpec();
* $response = $autoMlClient->updateTableSpec($tableSpec);
* } finally {
* $autoMlClient->close();
Expand Down Expand Up @@ -2121,7 +2121,7 @@ public function updateTableSpec($tableSpec, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedName = $autoMlClient->columnSpecName('[PROJECT]', '[LOCATION]', '[DATASET]', '[TABLE_SPEC]', '[COLUMN_SPEC]');
* $response = $autoMlClient->getColumnSpec($formattedName);
Expand Down Expand Up @@ -2176,7 +2176,7 @@ public function getColumnSpec($name, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $formattedParent = $autoMlClient->tableSpecName('[PROJECT]', '[LOCATION]', '[DATASET]', '[TABLE_SPEC]');
* // Iterate over pages of elements
Expand Down Expand Up @@ -2266,9 +2266,9 @@ public function listColumnSpecs($parent, array $optionalArgs = [])
*
* Sample code:
* ```
* $autoMlClient = new AutoMlClient();
* $autoMlClient = new Google\Cloud\AutoMl\V1beta1\AutoMlClient();
* try {
* $columnSpec = new ColumnSpec();
* $columnSpec = new Google\Cloud\AutoMl\V1beta1\ColumnSpec();
* $response = $autoMlClient->updateColumnSpec($columnSpec);
* } finally {
* $autoMlClient->close();
Expand Down
10 changes: 5 additions & 5 deletions AutoMl/src/V1beta1/Gapic/PredictionServiceGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* calls that map to API methods. Sample code to get started:
*
* ```
* $predictionServiceClient = new PredictionServiceClient();
* $predictionServiceClient = new Google\Cloud\AutoMl\V1beta1\PredictionServiceClient();
* try {
* $formattedName = $predictionServiceClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $payload = new ExamplePayload();
Expand Down Expand Up @@ -326,7 +326,7 @@ public function __construct(array $options = [])
*
* Sample code:
* ```
* $predictionServiceClient = new PredictionServiceClient();
* $predictionServiceClient = new Google\Cloud\AutoMl\V1beta1\PredictionServiceClient();
* try {
* $formattedName = $predictionServiceClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $payload = new ExamplePayload();
Expand Down Expand Up @@ -411,11 +411,11 @@ public function predict($name, $payload, array $optionalArgs = [])
*
* Sample code:
* ```
* $predictionServiceClient = new PredictionServiceClient();
* $predictionServiceClient = new Google\Cloud\AutoMl\V1beta1\PredictionServiceClient();
* try {
* $formattedName = $predictionServiceClient->modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
* $inputConfig = new BatchPredictInputConfig();
* $outputConfig = new BatchPredictOutputConfig();
* $inputConfig = new Google\Cloud\AutoMl\V1beta1\BatchPredictInputConfig();
* $outputConfig = new Google\Cloud\AutoMl\V1beta1\BatchPredictOutputConfig();
* $operationResponse = $predictionServiceClient->batchPredict($formattedName, $inputConfig, $outputConfig);
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
Expand Down
2 changes: 1 addition & 1 deletion AutoMl/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"updateTime": "2019-08-07T17:57:52.937163Z",
"updateTime": "2019-08-07T19:24:02.900108Z",
"sources": [
{
"generator": {
Expand Down
28 changes: 28 additions & 0 deletions AutoMl/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,31 @@
'tests/**/V1beta1/*Test.php',
r'Copyright \d{4}',
r'Copyright 2019')

# Fix class references in gapic samples
for version in ['V1beta1']:
pathExprs = [
'src/' + version + '/Gapic/AutoMlGapicClient.php',
'src/' + version + '/Gapic/PredictionServiceGapicClient.php'
]

for pathExpr in pathExprs:
types = {
'new AutoMlClient': r'new Google\\Cloud\\AutoMl\\' + version + r'\\AutoMlClient',
'new PredictionServiceClient': r'new Google\\Cloud\\AutoMl\\' + version + r'\\PredictionServiceClient',
'= AudioEncoding::': r'= Google\\Cloud\\Speech\\' + version + r'\\RecognitionConfig\\AudioEncoding::',
'new Dataset': r'new Google\\Cloud\\AutoMl\\' + version + r'\\Dataset',
'= new ModelExportOutputConfig': r'= new Google\\Cloud\\AutoMl\\' + version + r'\\ModelExportOutputConfig',
'= new ExportEvaluatedExamplesOutputConfig': r'= new Google\\Cloud\\AutoMl\\' + version + r'\\ExportEvaluatedExamplesOutputConfig',
'= new ExportEvaluatedExamplesOutputConfig': r'= new Google\\Cloud\\AutoMl\\' + version + r'\\ExportEvaluatedExamplesOutputConfig',
'= new TableSpec': r'= new Google\\Cloud\\AutoMl\\' + version + r'\\TableSpec',
'= new ColumnSpec': r'= new Google\\Cloud\\AutoMl\\' + version + r'\\ColumnSpec',
'= new BatchPredictInputConfig': r'= new Google\\Cloud\\AutoMl\\' + version + r'\\BatchPredictInputConfig',
'= new BatchPredictOutputConfig': r'= new Google\\Cloud\\AutoMl\\' + version + r'\\BatchPredictOutputConfig',
}

for search, replace in types.items():
s.replace(
pathExpr,
search,
replace)

0 comments on commit bb41559

Please sign in to comment.