Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update documentation and tests. #2006

Merged
merged 2 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Language/src/V1/Gapic/LanguageServiceGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
* calls that map to API methods. Sample code to get started:
*
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1\Document();
* $response = $languageServiceClient->analyzeSentiment($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -182,9 +182,9 @@ public function __construct(array $options = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1\Document();
* $response = $languageServiceClient->analyzeSentiment($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -233,9 +233,9 @@ public function analyzeSentiment($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1\Document();
* $response = $languageServiceClient->analyzeEntities($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -283,9 +283,9 @@ public function analyzeEntities($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1\Document();
* $response = $languageServiceClient->analyzeEntitySentiment($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -334,9 +334,9 @@ public function analyzeEntitySentiment($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1\Document();
* $response = $languageServiceClient->analyzeSyntax($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -383,9 +383,9 @@ public function analyzeSyntax($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1\Document();
* $response = $languageServiceClient->classifyText($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -427,20 +427,20 @@ public function classifyText($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient();
* try {
* $document = new Document();
* $features = new AnnotateTextRequest\Features();
* $document = new Google\Cloud\Language\V1\Document();
* $features = new Google\Cloud\Language\V1\AnnotateTextRequest\Features();
* $response = $languageServiceClient->annotateText($document, $features);
* } finally {
* $languageServiceClient->close();
* }
* ```
*
* @param Document $document Input document.
* @param AnnotateTextRequest\Features $features The enabled features.
* @param array $optionalArgs {
* Optional.
* @param Document $document Input document.
* @param Features $features The enabled features.
* @param array $optionalArgs {
* Optional.
*
* @type int $encodingType
* The encoding type used by the API to calculate offsets.
Expand Down
38 changes: 19 additions & 19 deletions Language/src/V1beta2/Gapic/LanguageServiceGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
* calls that map to API methods. Sample code to get started:
*
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1beta2\Document();
* $response = $languageServiceClient->analyzeSentiment($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -181,9 +181,9 @@ public function __construct(array $options = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1beta2\Document();
* $response = $languageServiceClient->analyzeSentiment($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -233,9 +233,9 @@ public function analyzeSentiment($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1beta2\Document();
* $response = $languageServiceClient->analyzeEntities($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -285,9 +285,9 @@ public function analyzeEntities($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1beta2\Document();
* $response = $languageServiceClient->analyzeEntitySentiment($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -336,9 +336,9 @@ public function analyzeEntitySentiment($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1beta2\Document();
* $response = $languageServiceClient->analyzeSyntax($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -385,9 +385,9 @@ public function analyzeSyntax($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient();
* try {
* $document = new Document();
* $document = new Google\Cloud\Language\V1beta2\Document();
* $response = $languageServiceClient->classifyText($document);
* } finally {
* $languageServiceClient->close();
Expand Down Expand Up @@ -429,20 +429,20 @@ public function classifyText($document, array $optionalArgs = [])
*
* Sample code:
* ```
* $languageServiceClient = new LanguageServiceClient();
* $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient();
* try {
* $document = new Document();
* $features = new AnnotateTextRequest\Features();
* $document = new Google\Cloud\Language\V1beta2\Document();
* $features = new Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features();
* $response = $languageServiceClient->annotateText($document, $features);
* } finally {
* $languageServiceClient->close();
* }
* ```
*
* @param Document $document Input document.
* @param AnnotateTextRequest\Features $features The enabled features.
* @param array $optionalArgs {
* Optional.
* @param Document $document Input document.
* @param Features $features The enabled features.
* @param array $optionalArgs {
* Optional.
*
* @type int $encodingType
* The encoding type used by the API to calculate offsets.
Expand Down
10 changes: 5 additions & 5 deletions Language/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-05-10T10:02:48.598957Z",
"updateTime": "2019-06-24T17:05:37.200555Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.19.0",
"dockerImage": "googleapis/artman@sha256:d3df563538225ac6caac45d8ad86499500211d1bcb2536955a6dbda15e1b368e"
"version": "0.29.0",
"dockerImage": "googleapis/artman@sha256:b79c8c20ee51e5302686c9d1294672d59290df1489be93749ef17d0172cc508d"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "07883be5bf3c3233095e99d8e92b8094f5d7084a",
"internalRef": "247530843"
"sha": "de1150ccad2a3daa4e265a0948bec54fdf9c8b54",
"internalRef": "254446031"
}
}
],
Expand Down
21 changes: 16 additions & 5 deletions Language/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,19 @@
r'Copyright \d{4}',
r'Copyright 2019')

# Use new namespaces
s.replace(
'src/*/Gapic/LanguageServiceGapicClient.php',
r'AnnotateTextRequest_Features',
r'AnnotateTextRequest\\Features')
# Fix class references in gapic samples
for version in ['V1', 'V1beta2']:
pathExpr = 'src/' + version + '/Gapic/LanguageServiceGapicClient.php'

types = {
'new LanguageServiceClient': r'new Google\\Cloud\\Language\\'+ version + r'\\LanguageServiceClient',
'new Document': r'new Google\\Cloud\\Language\\'+ version + r'\\Document',
'new Features': r'new Google\\Cloud\\Language\\'+ version + r'\\AnnotateTextRequest\\Features',
}

for search, replace in types.items():
s.replace(
pathExpr,
search,
replace
)
4 changes: 2 additions & 2 deletions Language/tests/System/V1beta2/LanguageServiceSmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Google\Cloud\Language\V1beta2\LanguageServiceClient;
use Google\ApiCore\Testing\GeneratedTest;
use Google\Cloud\Language\V1beta2\Document;
use Google\Cloud\Language\V1beta2\Document_Type;
use Google\Cloud\Language\V1beta2\Document\Type;

/**
* @group language
Expand All @@ -40,7 +40,7 @@ public function analyzeSentimentTest()
{
$languageServiceClient = new LanguageServiceClient();
$content = 'Hello, world!';
$type = Document_Type::PLAIN_TEXT;
$type = Type::PLAIN_TEXT;
$document = new Document();
$document->setContent($content);
$document->setType($type);
Expand Down
20 changes: 14 additions & 6 deletions Language/tests/Unit/V1/LanguageServiceClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use Google\Cloud\Language\V1\AnalyzeEntitySentimentResponse;
use Google\Cloud\Language\V1\AnalyzeSentimentResponse;
use Google\Cloud\Language\V1\AnalyzeSyntaxResponse;
use Google\Cloud\Language\V1\AnnotateTextRequest_Features;
use Google\Cloud\Language\V1\AnnotateTextRequest\Features;
use Google\Cloud\Language\V1\AnnotateTextResponse;
use Google\Cloud\Language\V1\ClassifyTextResponse;
use Google\Cloud\Language\V1\Document;
Expand All @@ -53,15 +53,23 @@ private function createTransport($deserialize = null)
return new MockTransport($deserialize);
}

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

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

return new LanguageServiceClient($options);
Expand Down Expand Up @@ -448,7 +456,7 @@ public function annotateTextTest()

// Mock request
$document = new Document();
$features = new AnnotateTextRequest_Features();
$features = new Features();

$response = $client->annotateText($document, $features);
$this->assertEquals($expectedResponse, $response);
Expand Down Expand Up @@ -492,7 +500,7 @@ public function annotateTextExceptionTest()

// Mock request
$document = new Document();
$features = new AnnotateTextRequest_Features();
$features = new Features();

try {
$client->annotateText($document, $features);
Expand Down
20 changes: 14 additions & 6 deletions Language/tests/Unit/V1beta2/LanguageServiceClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentResponse;
use Google\Cloud\Language\V1beta2\AnalyzeSentimentResponse;
use Google\Cloud\Language\V1beta2\AnalyzeSyntaxResponse;
use Google\Cloud\Language\V1beta2\AnnotateTextRequest_Features;
use Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features;
use Google\Cloud\Language\V1beta2\AnnotateTextResponse;
use Google\Cloud\Language\V1beta2\ClassifyTextResponse;
use Google\Cloud\Language\V1beta2\Document;
Expand All @@ -53,15 +53,23 @@ private function createTransport($deserialize = null)
return new MockTransport($deserialize);
}

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

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

return new LanguageServiceClient($options);
Expand Down Expand Up @@ -448,7 +456,7 @@ public function annotateTextTest()

// Mock request
$document = new Document();
$features = new AnnotateTextRequest_Features();
$features = new Features();

$response = $client->annotateText($document, $features);
$this->assertEquals($expectedResponse, $response);
Expand Down Expand Up @@ -492,7 +500,7 @@ public function annotateTextExceptionTest()

// Mock request
$document = new Document();
$features = new AnnotateTextRequest_Features();
$features = new Features();

try {
$client->annotateText($document, $features);
Expand Down