Skip to content

Commit

Permalink
feat!: move $languageCode to optional args (#2691)
Browse files Browse the repository at this point in the history
Co-authored-by: John Pedrie <[email protected]>
  • Loading branch information
yoshi-automation and jdpedrie authored Feb 13, 2020
1 parent 148f330 commit 4d2c5c4
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 187 deletions.
292 changes: 150 additions & 142 deletions metadata/V2/Session.php

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/V2/DetectIntentRequest.php

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

46 changes: 25 additions & 21 deletions src/V2/Gapic/IntentsGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,23 +653,23 @@ public function createIntent($parent, $intent, array $optionalArgs = [])
* $intentsClient = new IntentsClient();
* try {
* $intent = new Intent();
* $languageCode = '';
* $response = $intentsClient->updateIntent($intent, $languageCode);
* $response = $intentsClient->updateIntent($intent);
* } finally {
* $intentsClient->close();
* }
* ```
*
* @param Intent $intent Required. The intent to update.
* @param string $languageCode Optional. The language of training phrases, parameters and rich messages
* defined in `intent`. If not specified, the agent's default language is
* used. [Many
* languages](https://cloud.google.com/dialogflow/docs/reference/language)
* are supported. Note: languages must be enabled in the agent before they can
* be used.
* @param array $optionalArgs {
* Optional.
*
* @type string $languageCode
* Optional. The language of training phrases, parameters and rich messages
* defined in `intent`. If not specified, the agent's default language is
* used. [Many
* languages](https://cloud.google.com/dialogflow/docs/reference/language)
* are supported. Note: languages must be enabled in the agent before they can
* be used.
* @type FieldMask $updateMask
* Optional. The mask to control which fields get updated.
* @type int $intentView
Expand All @@ -687,11 +687,13 @@ public function createIntent($parent, $intent, array $optionalArgs = [])
* @throws ApiException if the remote call fails
* @experimental
*/
public function updateIntent($intent, $languageCode, array $optionalArgs = [])
public function updateIntent($intent, array $optionalArgs = [])
{
$request = new UpdateIntentRequest();
$request->setIntent($intent);
$request->setLanguageCode($languageCode);
if (isset($optionalArgs['languageCode'])) {
$request->setLanguageCode($optionalArgs['languageCode']);
}
if (isset($optionalArgs['updateMask'])) {
$request->setUpdateMask($optionalArgs['updateMask']);
}
Expand Down Expand Up @@ -774,8 +776,7 @@ public function deleteIntent($name, array $optionalArgs = [])
* $intentsClient = new IntentsClient();
* try {
* $formattedParent = $intentsClient->projectAgentName('[PROJECT]');
* $languageCode = '';
* $operationResponse = $intentsClient->batchUpdateIntents($formattedParent, $languageCode);
* $operationResponse = $intentsClient->batchUpdateIntents($formattedParent);
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
* $result = $operationResponse->getResult();
Expand All @@ -789,7 +790,7 @@ public function deleteIntent($name, array $optionalArgs = [])
* // Alternatively:
*
* // start the operation, keep the operation name, and resume later
* $operationResponse = $intentsClient->batchUpdateIntents($formattedParent, $languageCode);
* $operationResponse = $intentsClient->batchUpdateIntents($formattedParent);
* $operationName = $operationResponse->getName();
* // ... do other work
* $newOperationResponse = $intentsClient->resumeOperation($operationName, 'batchUpdateIntents');
Expand All @@ -811,12 +812,6 @@ public function deleteIntent($name, array $optionalArgs = [])
*
* @param string $parent Required. The name of the agent to update or create intents in.
* Format: `projects/<Project ID>/agent`.
* @param string $languageCode Optional. The language of training phrases, parameters and rich messages
* defined in `intents`. If not specified, the agent's default language is
* used. [Many
* languages](https://cloud.google.com/dialogflow/docs/reference/language)
* are supported. Note: languages must be enabled in the agent before they can
* be used.
* @param array $optionalArgs {
* Optional.
*
Expand All @@ -826,6 +821,13 @@ public function deleteIntent($name, array $optionalArgs = [])
* type) or JSON object. Note: The URI must start with "gs://".
* @type IntentBatch $intentBatchInline
* The collection of intents to update or create.
* @type string $languageCode
* Optional. The language of training phrases, parameters and rich messages
* defined in `intents`. If not specified, the agent's default language is
* used. [Many
* languages](https://cloud.google.com/dialogflow/docs/reference/language)
* are supported. Note: languages must be enabled in the agent before they can
* be used.
* @type FieldMask $updateMask
* Optional. The mask to control which fields get updated.
* @type int $intentView
Expand All @@ -843,17 +845,19 @@ public function deleteIntent($name, array $optionalArgs = [])
* @throws ApiException if the remote call fails
* @experimental
*/
public function batchUpdateIntents($parent, $languageCode, array $optionalArgs = [])
public function batchUpdateIntents($parent, array $optionalArgs = [])
{
$request = new BatchUpdateIntentsRequest();
$request->setParent($parent);
$request->setLanguageCode($languageCode);
if (isset($optionalArgs['intentBatchUri'])) {
$request->setIntentBatchUri($optionalArgs['intentBatchUri']);
}
if (isset($optionalArgs['intentBatchInline'])) {
$request->setIntentBatchInline($optionalArgs['intentBatchInline']);
}
if (isset($optionalArgs['languageCode'])) {
$request->setLanguageCode($optionalArgs['languageCode']);
}
if (isset($optionalArgs['updateMask'])) {
$request->setUpdateMask($optionalArgs['updateMask']);
}
Expand Down
2 changes: 2 additions & 0 deletions src/V2/OutputAudioConfig.php

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

4 changes: 2 additions & 2 deletions src/V2/resources/sessions_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
},
"methods": {
"DetectIntent": {
"timeout_millis": 230000,
"timeout_millis": 220000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"StreamingDetectIntent": {
"timeout_millis": 230000
"timeout_millis": 220000
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2020-01-21T16:52:30.593761Z",
"updateTime": "2020-02-12T13:58:52.064759Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.44.1",
"dockerImage": "googleapis/artman@sha256:5599b61e56a372d21b671969ee915fbca0f6c3a0daaeb898d01f8f685f1bbc8b"
"version": "0.45.0",
"dockerImage": "googleapis/artman@sha256:6aec9c34db0e4be221cdaf6faba27bdc07cfea846808b3d3b964dfce3a9a0f9b"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "7f0dab8177cf371ae019a082e2512de7ac102888",
"internalRef": "290326986"
"sha": "8a36b928873ff9c05b43859b9d4ea14cd205df57",
"internalRef": "294459768"
}
}
],
Expand Down
18 changes: 4 additions & 14 deletions tests/Unit/V2/IntentsClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,8 @@ public function updateIntentTest()

// Mock request
$intent = new Intent();
$languageCode = 'languageCode-412800396';

$response = $client->updateIntent($intent, $languageCode);
$response = $client->updateIntent($intent);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
Expand All @@ -383,9 +382,6 @@ public function updateIntentTest()
$actualValue = $actualRequestObject->getIntent();

$this->assertProtobufEquals($intent, $actualValue);
$actualValue = $actualRequestObject->getLanguageCode();

$this->assertProtobufEquals($languageCode, $actualValue);

$this->assertTrue($transport->isExhausted());
}
Expand Down Expand Up @@ -414,10 +410,9 @@ public function updateIntentExceptionTest()

// Mock request
$intent = new Intent();
$languageCode = 'languageCode-412800396';

try {
$client->updateIntent($intent, $languageCode);
$client->updateIntent($intent);
// If the $client method call did not throw, fail the test
$this->fail('Expected an ApiException, but no exception was thrown.');
} catch (ApiException $ex) {
Expand Down Expand Up @@ -536,9 +531,8 @@ public function batchUpdateIntentsTest()

// Mock request
$formattedParent = $client->projectAgentName('[PROJECT]');
$languageCode = 'languageCode-412800396';

$response = $client->batchUpdateIntents($formattedParent, $languageCode);
$response = $client->batchUpdateIntents($formattedParent);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
$apiRequests = $transport->popReceivedCalls();
Expand All @@ -552,9 +546,6 @@ public function batchUpdateIntentsTest()
$actualValue = $actualApiRequestObject->getParent();

$this->assertProtobufEquals($formattedParent, $actualValue);
$actualValue = $actualApiRequestObject->getLanguageCode();

$this->assertProtobufEquals($languageCode, $actualValue);

$expectedOperationsRequestObject = new GetOperationRequest();
$expectedOperationsRequestObject->setName('operations/batchUpdateIntentsTest');
Expand Down Expand Up @@ -618,9 +609,8 @@ public function batchUpdateIntentsExceptionTest()

// Mock request
$formattedParent = $client->projectAgentName('[PROJECT]');
$languageCode = 'languageCode-412800396';

$response = $client->batchUpdateIntents($formattedParent, $languageCode);
$response = $client->batchUpdateIntents($formattedParent);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());

Expand Down

0 comments on commit 4d2c5c4

Please sign in to comment.