diff --git a/translate/api/composer.json b/translate/api/composer.json index 28c773ab2f..73023a61f9 100644 --- a/translate/api/composer.json +++ b/translate/api/composer.json @@ -2,7 +2,7 @@ "name": "google/translate-sample", "type": "project", "require": { - "google/cloud": "^0.11.1", + "google/cloud": "^0.13", "symfony/console": "^3.1" }, "autoload": { diff --git a/translate/api/composer.lock b/translate/api/composer.lock index 8698e89f6a..0121591b16 100644 --- a/translate/api/composer.lock +++ b/translate/api/composer.lock @@ -4,7 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "52a8773db7a79b32b0dcf7f8a7234942", + "hash": "c784da86ce6ff73ea958f3b4049cd9ad", + "content-hash": "1cfe841f06a96a87237a296516626e66", "packages": [ { "name": "firebase/php-jwt", @@ -47,7 +48,7 @@ ], "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", "homepage": "https://github.com/firebase/php-jwt", - "time": "2015-07-22T18:31:08+00:00" + "time": "2015-07-22 18:31:08" }, { "name": "google/auth", @@ -95,25 +96,25 @@ "google", "oauth2" ], - "time": "2016-08-02T22:00:48+00:00" + "time": "2016-08-02 22:00:48" }, { "name": "google/cloud", - "version": "v0.11.1", + "version": "v0.13.0", "source": { "type": "git", "url": "https://github.com/GoogleCloudPlatform/google-cloud-php.git", - "reference": "7207d5b9bfb55cc732b082588f488150594141c2" + "reference": "397f0f648b6ff3895753ac8fcea154302eda5c7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/zipball/7207d5b9bfb55cc732b082588f488150594141c2", - "reference": "7207d5b9bfb55cc732b082588f488150594141c2", + "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/zipball/397f0f648b6ff3895753ac8fcea154302eda5c7f", + "reference": "397f0f648b6ff3895753ac8fcea154302eda5c7f", "shasum": "" }, "require": { "google/auth": "0.10", - "guzzlehttp/guzzle": "~5.2|~6.0", + "guzzlehttp/guzzle": "^5.3|^6.0", "guzzlehttp/psr7": "^1.2", "monolog/monolog": "~1", "php": ">=5.5", @@ -122,6 +123,8 @@ }, "require-dev": { "erusev/parsedown": "^1.6", + "google/gax": "^0.3", + "google/proto-client-php": "^0.5", "james-heinrich/getid3": "^1.9", "league/json-guard": "^0.3", "phpdocumentor/reflection": "^3.0", @@ -179,7 +182,7 @@ "translate", "vision" ], - "time": "2016-10-13T20:41:02+00:00" + "time": "2016-11-14 22:06:59" }, { "name": "guzzlehttp/guzzle", @@ -241,7 +244,7 @@ "rest", "web service" ], - "time": "2016-10-08T15:01:37+00:00" + "time": "2016-10-08 15:01:37" }, { "name": "guzzlehttp/promises", @@ -292,7 +295,7 @@ "keywords": [ "promise" ], - "time": "2016-05-18T16:56:05+00:00" + "time": "2016-05-18 16:56:05" }, { "name": "guzzlehttp/psr7", @@ -350,7 +353,7 @@ "stream", "uri" ], - "time": "2016-06-24T23:00:38+00:00" + "time": "2016-06-24 23:00:38" }, { "name": "monolog/monolog", @@ -428,7 +431,7 @@ "logging", "psr-3" ], - "time": "2016-07-29T03:23:52+00:00" + "time": "2016-07-29 03:23:52" }, { "name": "psr/cache", @@ -474,7 +477,7 @@ "psr", "psr-6" ], - "time": "2016-08-06T20:24:11+00:00" + "time": "2016-08-06 20:24:11" }, { "name": "psr/http-message", @@ -524,7 +527,7 @@ "request", "response" ], - "time": "2016-08-06T14:39:51+00:00" + "time": "2016-08-06 14:39:51" }, { "name": "psr/log", @@ -571,7 +574,7 @@ "psr", "psr-3" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2016-10-10 12:19:37" }, { "name": "rize/uri-template", @@ -615,7 +618,7 @@ "template", "uri" ], - "time": "2015-04-17T16:12:22+00:00" + "time": "2015-04-17 16:12:22" }, { "name": "symfony/console", @@ -676,7 +679,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-10-06T01:44:51+00:00" + "time": "2016-10-06 01:44:51" }, { "name": "symfony/debug", @@ -733,20 +736,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-09-06T11:02:40+00:00" + "time": "2016-09-06 11:02:40" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", "shasum": "" }, "require": { @@ -758,7 +761,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -792,7 +795,7 @@ "portable", "shim" ], - "time": "2016-05-18T14:26:46+00:00" + "time": "2016-11-14 01:06:16" } ], "packages-dev": [], diff --git a/translate/api/src/DetectLanguageCommand.php b/translate/api/src/DetectLanguageCommand.php index 2fb6f162c9..4a80345277 100644 --- a/translate/api/src/DetectLanguageCommand.php +++ b/translate/api/src/DetectLanguageCommand.php @@ -20,7 +20,6 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -38,7 +37,7 @@ protected function configure() ->setHelp(<<%command.name% command detects which language text was written in using the Google Cloud Translate API. - php %command.full_name% -k YOUR-API-KEY "Your text here" + php %command.full_name% "Your text here" EOF ) @@ -47,18 +46,11 @@ protected function configure() InputArgument::REQUIRED, 'The text to examine.' ) - ->addOption( - 'api-key', - 'k', - InputOption::VALUE_REQUIRED, - 'Your API key.' - ) ; } protected function execute(InputInterface $input, OutputInterface $output) { - $apiKey = $input->getOption('api-key'); $text = $input->getArgument('text'); require(__DIR__ . '/snippets/detect_language.php'); } diff --git a/translate/api/src/ListCodesCommand.php b/translate/api/src/ListCodesCommand.php index 7179884e30..5699c9e7a9 100644 --- a/translate/api/src/ListCodesCommand.php +++ b/translate/api/src/ListCodesCommand.php @@ -20,7 +20,6 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** @@ -37,22 +36,15 @@ protected function configure() ->setHelp(<<%command.name% command lists all the language codes in the Google Cloud Translate API. - php %command.full_name% -k YOUR-API-KEY + php %command.full_name% EOF ) - ->addOption( - 'api-key', - 'k', - InputOption::VALUE_REQUIRED, - 'Your API key.' - ) ; } protected function execute(InputInterface $input, OutputInterface $output) { - $apiKey = $input->getOption('api-key'); require(__DIR__ . '/snippets/list_codes.php'); } } diff --git a/translate/api/src/ListLanguagesCommand.php b/translate/api/src/ListLanguagesCommand.php index e06acd63cb..f5ff23a7c9 100644 --- a/translate/api/src/ListLanguagesCommand.php +++ b/translate/api/src/ListLanguagesCommand.php @@ -37,16 +37,10 @@ protected function configure() ->setHelp(<<%command.name% lists language codes and names in the Google Cloud Translate API. - php %command.full_name% -k YOUR-API-KEY -t en + php %command.full_name% -t en EOF ) - ->addOption( - 'api-key', - 'k', - InputOption::VALUE_REQUIRED, - 'Your API key.' - ) ->addOption( 'target-language', 't', @@ -58,7 +52,6 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - $apiKey = $input->getOption('api-key'); $targetLanguage = $input->getOption('target-language'); require(__DIR__ . '/snippets/list_languages.php'); } diff --git a/translate/api/src/TranslateCommand.php b/translate/api/src/TranslateCommand.php index d86b3f0510..e6a828be87 100644 --- a/translate/api/src/TranslateCommand.php +++ b/translate/api/src/TranslateCommand.php @@ -37,16 +37,10 @@ protected function configure() ->setHelp(<<%command.name% command transcribes audio using the Google Cloud Translate API. - php %command.full_name% -k YOUR-API-KEY -t ja "Hello World." + php %command.full_name% -t ja "Hello World." EOF ) - ->addOption( - 'api-key', - 'k', - InputOption::VALUE_REQUIRED, - 'Your API key.' - ) ->addArgument( 'text', InputArgument::REQUIRED, @@ -63,7 +57,6 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - $apiKey = $input->getOption('api-key'); $text = $input->getArgument('text'); $targetLanguage = $input->getOption('target-language'); require(__DIR__ . '/snippets/translate.php'); diff --git a/translate/api/src/snippets/detect_language.php b/translate/api/src/snippets/detect_language.php index 6a6faf1216..6ca2e42bf4 100644 --- a/translate/api/src/snippets/detect_language.php +++ b/translate/api/src/snippets/detect_language.php @@ -19,12 +19,9 @@ // [START translate_detect_language] use Google\Cloud\Translate\TranslateClient; -// $apiKey = 'YOUR-API-KEY'; // $text = 'The text whose language to detect. This will be detected as en.'; -$translate = new TranslateClient([ - 'key' => $apiKey, -]); +$translate = new TranslateClient(); $result = $translate->detectLanguage($text); print("Language code: $result[languageCode]\n"); print("Confidence: $result[confidence]\n"); diff --git a/translate/api/src/snippets/list_codes.php b/translate/api/src/snippets/list_codes.php index b07edd9049..f08786b870 100644 --- a/translate/api/src/snippets/list_codes.php +++ b/translate/api/src/snippets/list_codes.php @@ -19,11 +19,7 @@ // [START translate_list_codes] use Google\Cloud\Translate\TranslateClient; -// $apiKey = 'YOUR-API-KEY'; - -$translate = new TranslateClient([ - 'key' => $apiKey, -]); +$translate = new TranslateClient(); foreach ($translate->languages() as $code) { print("$code\n"); } diff --git a/translate/api/src/snippets/list_languages.php b/translate/api/src/snippets/list_languages.php index 7ae67b2bbe..80480aede4 100644 --- a/translate/api/src/snippets/list_languages.php +++ b/translate/api/src/snippets/list_languages.php @@ -21,12 +21,9 @@ // [START translate_list_language_names] use Google\Cloud\Translate\TranslateClient; -// $apiKey = 'YOUR-API-KEY' // $targetLanguage = 'en'; // Print the names of the languages in which language? -$translate = new TranslateClient([ - 'key' => $apiKey, -]); +$translate = new TranslateClient(); $result = $translate->localizedLanguages([ 'target' => $targetLanguage, ]); diff --git a/translate/api/src/snippets/translate.php b/translate/api/src/snippets/translate.php index 7810d9a327..b0b6e7321d 100644 --- a/translate/api/src/snippets/translate.php +++ b/translate/api/src/snippets/translate.php @@ -21,13 +21,10 @@ // [START translate_translate_text] use Google\Cloud\Translate\TranslateClient; -// $apiKey = 'YOUR-API-KEY' // $text = 'The text to translate." // $targetLanguage = 'ja'; // Which language to translate to? -$translate = new TranslateClient([ - 'key' => $apiKey -]); +$translate = new TranslateClient(); $result = $translate->translate($text, [ 'target' => $targetLanguage, ]); diff --git a/translate/api/test/CommandTest.php b/translate/api/test/CommandTest.php index 2aeeb9c982..76c709ff73 100644 --- a/translate/api/test/CommandTest.php +++ b/translate/api/test/CommandTest.php @@ -26,14 +26,6 @@ */ class CommandTest extends \PHPUnit_Framework_TestCase { - public function setUp() - { - $this->apiKey = getenv('GOOGLE_API_KEY'); - if (!$this->apiKey) { - $this->markTestSkipped('No api key was found.'); - } - } - public function testTranslate() { $application = new Application(); @@ -41,7 +33,6 @@ public function testTranslate() $commandTester = new CommandTester($application->get('translate')); $commandTester->execute( [ - '-k' => $this->apiKey, 'text' => 'Hello.', '-t' => 'ja', ], @@ -61,7 +52,6 @@ public function testTranslateBadLanguage() $this->setExpectedException('Google\Cloud\Exception\BadRequestException'); $commandTester->execute( [ - '-k' => $this->apiKey, 'text' => 'Hello.', '-t' => 'jp', ], @@ -76,7 +66,6 @@ public function testDetectLanguage() $commandTester = new CommandTester($application->get('detect')); $commandTester->execute( [ - '-k' => $this->apiKey, 'text' => 'Hello.', ], ['interactive' => false] @@ -92,7 +81,7 @@ public function testListCodes() $application = new Application(); $application->add(new ListCodesCommand()); $commandTester = new CommandTester($application->get('list-codes')); - $commandTester->execute(['-k' => $this->apiKey], ['interactive' => false]); + $commandTester->execute([], ['interactive' => false]); $this->assertEquals(0, $commandTester->getStatusCode()); $display = $this->getActualOutput(); $this->assertContains("\nen\n", $display); @@ -105,7 +94,7 @@ public function testListLanguagesInEnglish() $application->add(new ListLanguagesCommand()); $commandTester = new CommandTester($application->get('list-langs')); $commandTester->execute( - ['-k' => $this->apiKey, '-t' => 'en'], + ['-t' => 'en'], ['interactive' => false] ); $this->assertEquals(0, $commandTester->getStatusCode()); @@ -119,7 +108,7 @@ public function testListLanguagesInJapanese() $application->add(new ListLanguagesCommand()); $commandTester = new CommandTester($application->get('list-langs')); $commandTester->execute( - ['-k' => $this->apiKey, '-t' => 'ja'], + ['-t' => 'ja'], ['interactive' => false] ); $this->assertEquals(0, $commandTester->getStatusCode()); diff --git a/translate/quickstart/composer.json b/translate/quickstart/composer.json index c41b6683f5..e868395249 100644 --- a/translate/quickstart/composer.json +++ b/translate/quickstart/composer.json @@ -1,6 +1,6 @@ { "require": { "php": ">=5.4", - "google/cloud": "0.10" + "google/cloud": "0.13" } } diff --git a/translate/quickstart/composer.lock b/translate/quickstart/composer.lock index 0b6d1c4b50..b23a6cb782 100644 --- a/translate/quickstart/composer.lock +++ b/translate/quickstart/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f75b529e9f42e9c698da7cbb22ae4f13", - "content-hash": "4c7836060be1fc699affa599c19eb06d", + "hash": "3f3256c780cdf77d34fd611bfef499b9", + "content-hash": "7fae82527010253be8d259fd5f1fd952", "packages": [ { "name": "firebase/php-jwt", @@ -100,21 +100,21 @@ }, { "name": "google/cloud", - "version": "v0.10.0", + "version": "v0.13.0", "source": { "type": "git", "url": "https://github.com/GoogleCloudPlatform/google-cloud-php.git", - "reference": "ad867d788e855b3423fb8866b15ea23fbe844cbe" + "reference": "397f0f648b6ff3895753ac8fcea154302eda5c7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/zipball/ad867d788e855b3423fb8866b15ea23fbe844cbe", - "reference": "ad867d788e855b3423fb8866b15ea23fbe844cbe", + "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/zipball/397f0f648b6ff3895753ac8fcea154302eda5c7f", + "reference": "397f0f648b6ff3895753ac8fcea154302eda5c7f", "shasum": "" }, "require": { "google/auth": "0.10", - "guzzlehttp/guzzle": "~5.2|~6.0", + "guzzlehttp/guzzle": "^5.3|^6.0", "guzzlehttp/psr7": "^1.2", "monolog/monolog": "~1", "php": ">=5.5", @@ -123,6 +123,8 @@ }, "require-dev": { "erusev/parsedown": "^1.6", + "google/gax": "^0.3", + "google/proto-client-php": "^0.5", "james-heinrich/getid3": "^1.9", "league/json-guard": "^0.3", "phpdocumentor/reflection": "^3.0", @@ -180,20 +182,20 @@ "translate", "vision" ], - "time": "2016-10-05 15:18:51" + "time": "2016-11-14 22:06:59" }, { "name": "guzzlehttp/guzzle", - "version": "6.2.1", + "version": "6.2.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427" + "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ebf29dee597f02f09f4d5bbecc68230ea9b08f60", + "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60", "shasum": "" }, "require": { @@ -242,7 +244,7 @@ "rest", "web service" ], - "time": "2016-07-15 17:22:37" + "time": "2016-10-08 15:01:37" }, { "name": "guzzlehttp/promises", @@ -529,16 +531,16 @@ }, { "name": "psr/log", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0" + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/5277094ed527a1c4477177d102fe4c53551953e0", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", "shasum": "" }, "require": { @@ -572,7 +574,7 @@ "psr", "psr-3" ], - "time": "2016-09-19 16:02:08" + "time": "2016-10-10 12:19:37" }, { "name": "rize/uri-template", diff --git a/translate/quickstart/quickstart.php b/translate/quickstart/quickstart.php index 070a0fc0a5..c20d64898e 100644 --- a/translate/quickstart/quickstart.php +++ b/translate/quickstart/quickstart.php @@ -7,12 +7,12 @@ # Imports the Google Cloud client library use Google\Cloud\Translate\TranslateClient; -# Your Translate API key -$apiKey = 'YOUR_API_KEY'; +# Your Google Cloud Platform project ID +$projectId = 'YOUR_PROJECT_ID'; # Instantiates a client $translate = new TranslateClient([ - 'key' => $apiKey + 'projectId' => $projectId ]); # The text to translate diff --git a/translate/quickstart/test/quickstartTest.php b/translate/quickstart/test/quickstartTest.php index add093ea35..5fffd081ac 100644 --- a/translate/quickstart/test/quickstartTest.php +++ b/translate/quickstart/test/quickstartTest.php @@ -18,15 +18,15 @@ class quickstartTest extends PHPUnit_Framework_TestCase { public function testQuickstart() { - if (!$key = getenv('GOOGLE_API_KEY')) { - $this->markTestSkipped('GOOGLE_API_KEY must be set.'); + if (!$projectId = getenv('GOOGLE_PROJECT_ID')) { + $this->markTestSkipped('GOOGLE_PROJECT_ID must be set.'); } $file = sys_get_temp_dir() . '/translate_quickstart.php'; $contents = file_get_contents(__DIR__ . '/../quickstart.php'); $contents = str_replace( - ['YOUR_API_KEY', '__DIR__'], - [$key, sprintf('"%s/.."', __DIR__)], + ['YOUR_PROJECT_ID', '__DIR__'], + [$projectId, sprintf('"%s/.."', __DIR__)], $contents ); file_put_contents($file, $contents);