Skip to content

Commit

Permalink
docs: Update documentation and generated tests. (#2013)
Browse files Browse the repository at this point in the history
* [CHANGE ME] Re-generated Speech to pick up changes in the API or client library generator.

* Fix samples class references
  • Loading branch information
yoshi-automation authored and dwsupplee committed Jun 24, 2019
1 parent c463e47 commit aba343b
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 59 deletions.
28 changes: 14 additions & 14 deletions Speech/src/V1/Gapic/SpeechGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@
* calls that map to API methods. Sample code to get started:
*
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1\SpeechClient();
* try {
* $encoding = RecognitionConfig\AudioEncoding::FLAC;
* $encoding = Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding::FLAC;
* $sampleRateHertz = 44100;
* $languageCode = 'en-US';
* $config = new RecognitionConfig();
* $config = new Google\Cloud\Speech\V1\RecognitionConfig();
* $config->setEncoding($encoding);
* $config->setSampleRateHertz($sampleRateHertz);
* $config->setLanguageCode($languageCode);
* $uri = 'gs://bucket_name/file_name.flac';
* $audio = new RecognitionAudio();
* $audio = new Google\Cloud\Speech\V1\RecognitionAudio();
* $audio->setUri($uri);
* $response = $speechClient->recognize($config, $audio);
* } finally {
Expand Down Expand Up @@ -225,17 +225,17 @@ public function __construct(array $options = [])
*
* Sample code:
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1\SpeechClient();
* try {
* $encoding = RecognitionConfig\AudioEncoding::FLAC;
* $encoding = Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding::FLAC;
* $sampleRateHertz = 44100;
* $languageCode = 'en-US';
* $config = new RecognitionConfig();
* $config = new Google\Cloud\Speech\V1\RecognitionConfig();
* $config->setEncoding($encoding);
* $config->setSampleRateHertz($sampleRateHertz);
* $config->setLanguageCode($languageCode);
* $uri = 'gs://bucket_name/file_name.flac';
* $audio = new RecognitionAudio();
* $audio = new Google\Cloud\Speech\V1\RecognitionAudio();
* $audio->setUri($uri);
* $response = $speechClient->recognize($config, $audio);
* } finally {
Expand Down Expand Up @@ -283,17 +283,17 @@ public function recognize($config, $audio, array $optionalArgs = [])
*
* Sample code:
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1\SpeechClient();
* try {
* $encoding = RecognitionConfig\AudioEncoding::FLAC;
* $encoding = Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding::FLAC;
* $sampleRateHertz = 44100;
* $languageCode = 'en-US';
* $config = new RecognitionConfig();
* $config = new Google\Cloud\Speech\V1\RecognitionConfig();
* $config->setEncoding($encoding);
* $config->setSampleRateHertz($sampleRateHertz);
* $config->setLanguageCode($languageCode);
* $uri = 'gs://bucket_name/file_name.flac';
* $audio = new RecognitionAudio();
* $audio = new Google\Cloud\Speech\V1\RecognitionAudio();
* $audio->setUri($uri);
* $operationResponse = $speechClient->longRunningRecognize($config, $audio);
* $operationResponse->pollUntilComplete();
Expand Down Expand Up @@ -367,9 +367,9 @@ public function longRunningRecognize($config, $audio, array $optionalArgs = [])
*
* Sample code:
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1\SpeechClient();
* try {
* $request = new StreamingRecognizeRequest();
* $request = new Google\Cloud\Speech\V1\StreamingRecognizeRequest();
* // Write all requests to the server, then read all responses until the
* // stream is complete
* $requests = [$request];
Expand Down
28 changes: 14 additions & 14 deletions Speech/src/V1p1beta1/Gapic/SpeechGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@
* calls that map to API methods. Sample code to get started:
*
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1p1beta1\SpeechClient();
* try {
* $encoding = RecognitionConfig\AudioEncoding::FLAC;
* $encoding = Google\Cloud\Speech\V1p1beta1\RecognitionConfig\AudioEncoding::FLAC;
* $sampleRateHertz = 44100;
* $languageCode = 'en-US';
* $config = new RecognitionConfig();
* $config = new Google\Cloud\Speech\V1p1beta1\RecognitionConfig();
* $config->setEncoding($encoding);
* $config->setSampleRateHertz($sampleRateHertz);
* $config->setLanguageCode($languageCode);
* $uri = 'gs://bucket_name/file_name.flac';
* $audio = new RecognitionAudio();
* $audio = new Google\Cloud\Speech\V1p1beta1\RecognitionAudio();
* $audio->setUri($uri);
* $response = $speechClient->recognize($config, $audio);
* } finally {
Expand Down Expand Up @@ -225,17 +225,17 @@ public function __construct(array $options = [])
*
* Sample code:
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1p1beta1\SpeechClient();
* try {
* $encoding = RecognitionConfig\AudioEncoding::FLAC;
* $encoding = Google\Cloud\Speech\V1p1beta1\RecognitionConfig\AudioEncoding::FLAC;
* $sampleRateHertz = 44100;
* $languageCode = 'en-US';
* $config = new RecognitionConfig();
* $config = new Google\Cloud\Speech\V1p1beta1\RecognitionConfig();
* $config->setEncoding($encoding);
* $config->setSampleRateHertz($sampleRateHertz);
* $config->setLanguageCode($languageCode);
* $uri = 'gs://bucket_name/file_name.flac';
* $audio = new RecognitionAudio();
* $audio = new Google\Cloud\Speech\V1p1beta1\RecognitionAudio();
* $audio->setUri($uri);
* $response = $speechClient->recognize($config, $audio);
* } finally {
Expand Down Expand Up @@ -283,17 +283,17 @@ public function recognize($config, $audio, array $optionalArgs = [])
*
* Sample code:
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1p1beta1\SpeechClient();
* try {
* $encoding = RecognitionConfig\AudioEncoding::FLAC;
* $encoding = Google\Cloud\Speech\V1p1beta1\RecognitionConfig\AudioEncoding::FLAC;
* $sampleRateHertz = 44100;
* $languageCode = 'en-US';
* $config = new RecognitionConfig();
* $config = new Google\Cloud\Speech\V1p1beta1\RecognitionConfig();
* $config->setEncoding($encoding);
* $config->setSampleRateHertz($sampleRateHertz);
* $config->setLanguageCode($languageCode);
* $uri = 'gs://bucket_name/file_name.flac';
* $audio = new RecognitionAudio();
* $audio = new Google\Cloud\Speech\V1p1beta1\RecognitionAudio();
* $audio->setUri($uri);
* $operationResponse = $speechClient->longRunningRecognize($config, $audio);
* $operationResponse->pollUntilComplete();
Expand Down Expand Up @@ -367,9 +367,9 @@ public function longRunningRecognize($config, $audio, array $optionalArgs = [])
*
* Sample code:
* ```
* $speechClient = new SpeechClient();
* $speechClient = new Google\Cloud\Speech\V1p1beta1\SpeechClient();
* try {
* $request = new StreamingRecognizeRequest();
* $request = new Google\Cloud\Speech\V1p1beta1\StreamingRecognizeRequest();
* // Write all requests to the server, then read all responses until the
* // stream is complete
* $requests = [$request];
Expand Down
20 changes: 20 additions & 0 deletions Speech/src/V1p1beta1/SpeechContext.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Speech/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-05-23T10:04:01.116727Z",
"updateTime": "2019-06-24T18:19:33.829099Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.20.0",
"dockerImage": "googleapis/artman@sha256:3246adac900f4bdbd62920e80de2e5877380e44036b3feae13667ec255ebf5ec"
"version": "0.29.0",
"dockerImage": "googleapis/artman@sha256:b79c8c20ee51e5302686c9d1294672d59290df1489be93749ef17d0172cc508d"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "f792303254ea54442d03ca470ffb38930bda7806",
"internalRef": "249516437"
"sha": "de1150ccad2a3daa4e265a0948bec54fdf9c8b54",
"internalRef": "254446031"
}
}
],
Expand Down
25 changes: 19 additions & 6 deletions Speech/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,27 @@
r'Copyright \d{4}',
r'Copyright 2018')

# Use new namespace in the doc sample. See
# https://github.com/googleapis/gapic-generator/issues/2141
s.replace(
'src/*/Gapic/SpeechGapicClient.php',
r'RecognitionConfig_AudioEncoding',
r'RecognitionConfig\\AudioEncoding')
# Change the wording for the deprecation warning.
s.replace(
'src/*/*_*.php',
r'will be removed in the next major release',
'will be removed in a future release')

# Fix class references in gapic samples
for version in ['V1', 'V1p1beta1']:
pathExpr = 'src/' + version + '/Gapic/SpeechGapicClient.php'

types = {
'new SpeechClient': r'new Google\\Cloud\\Speech\\' + version + r'\\SpeechClient',
'= AudioEncoding::': r'= Google\\Cloud\\Speech\\' + version + r'\\RecognitionConfig\\AudioEncoding::',
'new RecognitionConfig': r'new Google\\Cloud\\Speech\\' + version + r'\\RecognitionConfig',
'new RecognitionAudio': r'new Google\\Cloud\\Speech\\' + version + r'\\RecognitionAudio',
'new StreamingRecognizeRequest': r'new Google\\Cloud\\Speech\\' + version + r'\\StreamingRecognizeRequest',
}

for search, replace in types.items():
s.replace(
pathExpr,
search,
replace
)
4 changes: 2 additions & 2 deletions Speech/tests/System/V1/SpeechSmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Google\ApiCore\Testing\GeneratedTest;
use Google\Cloud\Speech\V1\RecognitionAudio;
use Google\Cloud\Speech\V1\RecognitionConfig;
use Google\Cloud\Speech\V1\RecognitionConfig_AudioEncoding;
use Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding;

/**
* @group speech
Expand All @@ -42,7 +42,7 @@ public function recognizeTest()
$speechClient = new SpeechClient();
$languageCode = 'en-US';
$sampleRateHertz = 44100;
$encoding = RecognitionConfig_AudioEncoding::FLAC;
$encoding = AudioEncoding::FLAC;
$config = new RecognitionConfig();
$config->setLanguageCode($languageCode);
$config->setSampleRateHertz($sampleRateHertz);
Expand Down
4 changes: 2 additions & 2 deletions Speech/tests/System/V1p1beta1/SpeechSmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Google\ApiCore\Testing\GeneratedTest;
use Google\Cloud\Speech\V1p1beta1\RecognitionAudio;
use Google\Cloud\Speech\V1p1beta1\RecognitionConfig;
use Google\Cloud\Speech\V1p1beta1\RecognitionConfig_AudioEncoding;
use Google\Cloud\Speech\V1p1beta1\RecognitionConfig\AudioEncoding;

/**
* @group speech
Expand All @@ -42,7 +42,7 @@ public function recognizeTest()
$speechClient = new SpeechClient();
$languageCode = 'en-US';
$sampleRateHertz = 44100;
$encoding = RecognitionConfig_AudioEncoding::FLAC;
$encoding = AudioEncoding::FLAC;
$config = new RecognitionConfig();
$config->setLanguageCode($languageCode);
$config->setSampleRateHertz($sampleRateHertz);
Expand Down
26 changes: 18 additions & 8 deletions Speech/tests/Unit/V1/SpeechClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use Google\Cloud\Speech\V1\LongRunningRecognizeResponse;
use Google\Cloud\Speech\V1\RecognitionAudio;
use Google\Cloud\Speech\V1\RecognitionConfig;
use Google\Cloud\Speech\V1\RecognitionConfig_AudioEncoding;
use Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding;
use Google\Cloud\Speech\V1\RecognizeResponse;
use Google\Cloud\Speech\V1\StreamingRecognizeRequest;
use Google\Cloud\Speech\V1\StreamingRecognizeResponse;
Expand All @@ -56,15 +56,23 @@ private function createTransport($deserialize = null)
return new MockTransport($deserialize);
}

/**
* @return CredentialsWrapper
*/
private function createCredentials()
{
return $this->getMockBuilder(CredentialsWrapper::class)
->disableOriginalConstructor()
->getMock();
}

/**
* @return SpeechClient
*/
private function createClient(array $options = [])
{
$options += [
'credentials' => $this->getMockBuilder(CredentialsWrapper::class)
->disableOriginalConstructor()
->getMock(),
'credentials' => $this->createCredentials(),
];

return new SpeechClient($options);
Expand All @@ -85,7 +93,7 @@ public function recognizeTest()
$transport->addResponse($expectedResponse);

// Mock request
$encoding = RecognitionConfig_AudioEncoding::FLAC;
$encoding = AudioEncoding::FLAC;
$sampleRateHertz = 44100;
$languageCode = 'en-US';
$config = new RecognitionConfig();
Expand Down Expand Up @@ -137,7 +145,7 @@ public function recognizeExceptionTest()
$transport->addResponse(null, $status);

// Mock request
$encoding = RecognitionConfig_AudioEncoding::FLAC;
$encoding = AudioEncoding::FLAC;
$sampleRateHertz = 44100;
$languageCode = 'en-US';
$config = new RecognitionConfig();
Expand Down Expand Up @@ -171,6 +179,7 @@ public function longRunningRecognizeTest()
$operationsClient = new OperationsClient([
'serviceAddress' => '',
'transport' => $operationsTransport,
'credentials' => $this->createCredentials(),
]);
$transport = $this->createTransport();
$client = $this->createClient([
Expand All @@ -196,7 +205,7 @@ public function longRunningRecognizeTest()
$operationsTransport->addResponse($completeOperation);

// Mock request
$encoding = RecognitionConfig_AudioEncoding::FLAC;
$encoding = AudioEncoding::FLAC;
$sampleRateHertz = 44100;
$languageCode = 'en-US';
$config = new RecognitionConfig();
Expand Down Expand Up @@ -256,6 +265,7 @@ public function longRunningRecognizeExceptionTest()
$operationsClient = new OperationsClient([
'serviceAddress' => '',
'transport' => $operationsTransport,
'credentials' => $this->createCredentials(),
]);
$transport = $this->createTransport();
$client = $this->createClient([
Expand Down Expand Up @@ -285,7 +295,7 @@ public function longRunningRecognizeExceptionTest()
$operationsTransport->addResponse(null, $status);

// Mock request
$encoding = RecognitionConfig_AudioEncoding::FLAC;
$encoding = AudioEncoding::FLAC;
$sampleRateHertz = 44100;
$languageCode = 'en-US';
$config = new RecognitionConfig();
Expand Down
Loading

0 comments on commit aba343b

Please sign in to comment.