[e3d4e0a] | 1 | <?php
|
---|
| 2 | /*
|
---|
| 3 | * Copyright 2014 Google Inc.
|
---|
| 4 | *
|
---|
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
---|
| 6 | * use this file except in compliance with the License. You may obtain a copy of
|
---|
| 7 | * the License at
|
---|
| 8 | *
|
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 10 | *
|
---|
| 11 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
---|
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
---|
| 14 | * License for the specific language governing permissions and limitations under
|
---|
| 15 | * the License.
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | namespace Google\Service\Translate\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Translate\AdaptiveMtTranslateRequest;
|
---|
| 21 | use Google\Service\Translate\AdaptiveMtTranslateResponse;
|
---|
| 22 | use Google\Service\Translate\BatchTranslateDocumentRequest;
|
---|
| 23 | use Google\Service\Translate\BatchTranslateTextRequest;
|
---|
| 24 | use Google\Service\Translate\DetectLanguageRequest;
|
---|
| 25 | use Google\Service\Translate\DetectLanguageResponse;
|
---|
| 26 | use Google\Service\Translate\ListLocationsResponse;
|
---|
| 27 | use Google\Service\Translate\Location;
|
---|
| 28 | use Google\Service\Translate\Operation;
|
---|
| 29 | use Google\Service\Translate\RomanizeTextRequest;
|
---|
| 30 | use Google\Service\Translate\RomanizeTextResponse;
|
---|
| 31 | use Google\Service\Translate\SupportedLanguages;
|
---|
| 32 | use Google\Service\Translate\TranslateDocumentRequest;
|
---|
| 33 | use Google\Service\Translate\TranslateDocumentResponse;
|
---|
| 34 | use Google\Service\Translate\TranslateTextRequest;
|
---|
| 35 | use Google\Service\Translate\TranslateTextResponse;
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * The "locations" collection of methods.
|
---|
| 39 | * Typical usage is:
|
---|
| 40 | * <code>
|
---|
| 41 | * $translateService = new Google\Service\Translate(...);
|
---|
| 42 | * $locations = $translateService->projects_locations;
|
---|
| 43 | * </code>
|
---|
| 44 | */
|
---|
| 45 | class ProjectsLocations extends \Google\Service\Resource
|
---|
| 46 | {
|
---|
| 47 | /**
|
---|
| 48 | * Translate text using Adaptive MT. (locations.adaptiveMtTranslate)
|
---|
| 49 | *
|
---|
| 50 | * @param string $parent Required. Location to make a regional call. Format:
|
---|
| 51 | * `projects/{project-number-or-id}/locations/{location-id}`.
|
---|
| 52 | * @param AdaptiveMtTranslateRequest $postBody
|
---|
| 53 | * @param array $optParams Optional parameters.
|
---|
| 54 | * @return AdaptiveMtTranslateResponse
|
---|
| 55 | * @throws \Google\Service\Exception
|
---|
| 56 | */
|
---|
| 57 | public function adaptiveMtTranslate($parent, AdaptiveMtTranslateRequest $postBody, $optParams = [])
|
---|
| 58 | {
|
---|
| 59 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 60 | $params = array_merge($params, $optParams);
|
---|
| 61 | return $this->call('adaptiveMtTranslate', [$params], AdaptiveMtTranslateResponse::class);
|
---|
| 62 | }
|
---|
| 63 | /**
|
---|
| 64 | * Translates a large volume of document in asynchronous batch mode. This
|
---|
| 65 | * function provides real-time output as the inputs are being processed. If
|
---|
| 66 | * caller cancels a request, the partial results (for an input file, it's all or
|
---|
| 67 | * nothing) may still be available on the specified output location. This call
|
---|
| 68 | * returns immediately and you can use google.longrunning.Operation.name to poll
|
---|
| 69 | * the status of the call. (locations.batchTranslateDocument)
|
---|
| 70 | *
|
---|
| 71 | * @param string $parent Required. Location to make a regional call. Format:
|
---|
| 72 | * `projects/{project-number-or-id}/locations/{location-id}`. The `global`
|
---|
| 73 | * location is not supported for batch translation. Only AutoML Translation
|
---|
| 74 | * models or glossaries within the same region (have the same location-id) can
|
---|
| 75 | * be used, otherwise an INVALID_ARGUMENT (400) error is returned.
|
---|
| 76 | * @param BatchTranslateDocumentRequest $postBody
|
---|
| 77 | * @param array $optParams Optional parameters.
|
---|
| 78 | * @return Operation
|
---|
| 79 | * @throws \Google\Service\Exception
|
---|
| 80 | */
|
---|
| 81 | public function batchTranslateDocument($parent, BatchTranslateDocumentRequest $postBody, $optParams = [])
|
---|
| 82 | {
|
---|
| 83 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 84 | $params = array_merge($params, $optParams);
|
---|
| 85 | return $this->call('batchTranslateDocument', [$params], Operation::class);
|
---|
| 86 | }
|
---|
| 87 | /**
|
---|
| 88 | * Translates a large volume of text in asynchronous batch mode. This function
|
---|
| 89 | * provides real-time output as the inputs are being processed. If caller
|
---|
| 90 | * cancels a request, the partial results (for an input file, it's all or
|
---|
| 91 | * nothing) may still be available on the specified output location. This call
|
---|
| 92 | * returns immediately and you can use google.longrunning.Operation.name to poll
|
---|
| 93 | * the status of the call. (locations.batchTranslateText)
|
---|
| 94 | *
|
---|
| 95 | * @param string $parent Required. Location to make a call. Must refer to a
|
---|
| 96 | * caller's project. Format: `projects/{project-number-or-
|
---|
| 97 | * id}/locations/{location-id}`. The `global` location is not supported for
|
---|
| 98 | * batch translation. Only AutoML Translation models or glossaries within the
|
---|
| 99 | * same region (have the same location-id) can be used, otherwise an
|
---|
| 100 | * INVALID_ARGUMENT (400) error is returned.
|
---|
| 101 | * @param BatchTranslateTextRequest $postBody
|
---|
| 102 | * @param array $optParams Optional parameters.
|
---|
| 103 | * @return Operation
|
---|
| 104 | * @throws \Google\Service\Exception
|
---|
| 105 | */
|
---|
| 106 | public function batchTranslateText($parent, BatchTranslateTextRequest $postBody, $optParams = [])
|
---|
| 107 | {
|
---|
| 108 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 109 | $params = array_merge($params, $optParams);
|
---|
| 110 | return $this->call('batchTranslateText', [$params], Operation::class);
|
---|
| 111 | }
|
---|
| 112 | /**
|
---|
| 113 | * Detects the language of text within a request. (locations.detectLanguage)
|
---|
| 114 | *
|
---|
| 115 | * @param string $parent Required. Project or location to make a call. Must
|
---|
| 116 | * refer to a caller's project. Format: `projects/{project-number-or-
|
---|
| 117 | * id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global
|
---|
| 118 | * calls, use `projects/{project-number-or-id}/locations/global` or
|
---|
| 119 | * `projects/{project-number-or-id}`. Only models within the same region (has
|
---|
| 120 | * same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is
|
---|
| 121 | * returned.
|
---|
| 122 | * @param DetectLanguageRequest $postBody
|
---|
| 123 | * @param array $optParams Optional parameters.
|
---|
| 124 | * @return DetectLanguageResponse
|
---|
| 125 | * @throws \Google\Service\Exception
|
---|
| 126 | */
|
---|
| 127 | public function detectLanguage($parent, DetectLanguageRequest $postBody, $optParams = [])
|
---|
| 128 | {
|
---|
| 129 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 130 | $params = array_merge($params, $optParams);
|
---|
| 131 | return $this->call('detectLanguage', [$params], DetectLanguageResponse::class);
|
---|
| 132 | }
|
---|
| 133 | /**
|
---|
| 134 | * Gets information about a location. (locations.get)
|
---|
| 135 | *
|
---|
| 136 | * @param string $name Resource name for the location.
|
---|
| 137 | * @param array $optParams Optional parameters.
|
---|
| 138 | * @return Location
|
---|
| 139 | * @throws \Google\Service\Exception
|
---|
| 140 | */
|
---|
| 141 | public function get($name, $optParams = [])
|
---|
| 142 | {
|
---|
| 143 | $params = ['name' => $name];
|
---|
| 144 | $params = array_merge($params, $optParams);
|
---|
| 145 | return $this->call('get', [$params], Location::class);
|
---|
| 146 | }
|
---|
| 147 | /**
|
---|
| 148 | * Returns a list of supported languages for translation.
|
---|
| 149 | * (locations.getSupportedLanguages)
|
---|
| 150 | *
|
---|
| 151 | * @param string $parent Required. Project or location to make a call. Must
|
---|
| 152 | * refer to a caller's project. Format: `projects/{project-number-or-id}` or
|
---|
| 153 | * `projects/{project-number-or-id}/locations/{location-id}`. For global calls,
|
---|
| 154 | * use `projects/{project-number-or-id}/locations/global` or `projects/{project-
|
---|
| 155 | * number-or-id}`. Non-global location is required for AutoML models. Only
|
---|
| 156 | * models within the same region (have same location-id) can be used, otherwise
|
---|
| 157 | * an INVALID_ARGUMENT (400) error is returned.
|
---|
| 158 | * @param array $optParams Optional parameters.
|
---|
| 159 | *
|
---|
| 160 | * @opt_param string displayLanguageCode Optional. The language to use to return
|
---|
| 161 | * localized, human readable names of supported languages. If missing, then
|
---|
| 162 | * display names are not returned in a response.
|
---|
| 163 | * @opt_param string model Optional. Get supported languages of this model. The
|
---|
| 164 | * format depends on model type: - AutoML Translation models:
|
---|
| 165 | * `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` -
|
---|
| 166 | * General (built-in) models: `projects/{project-number-or-
|
---|
| 167 | * id}/locations/{location-id}/models/general/nmt`, Returns languages supported
|
---|
| 168 | * by the specified model. If missing, we get supported languages of Google
|
---|
| 169 | * general NMT model.
|
---|
| 170 | * @return SupportedLanguages
|
---|
| 171 | * @throws \Google\Service\Exception
|
---|
| 172 | */
|
---|
| 173 | public function getSupportedLanguages($parent, $optParams = [])
|
---|
| 174 | {
|
---|
| 175 | $params = ['parent' => $parent];
|
---|
| 176 | $params = array_merge($params, $optParams);
|
---|
| 177 | return $this->call('getSupportedLanguages', [$params], SupportedLanguages::class);
|
---|
| 178 | }
|
---|
| 179 | /**
|
---|
| 180 | * Lists information about the supported locations for this service.
|
---|
| 181 | * (locations.listProjectsLocations)
|
---|
| 182 | *
|
---|
| 183 | * @param string $name The resource that owns the locations collection, if
|
---|
| 184 | * applicable.
|
---|
| 185 | * @param array $optParams Optional parameters.
|
---|
| 186 | *
|
---|
| 187 | * @opt_param string filter A filter to narrow down results to a preferred
|
---|
| 188 | * subset. The filtering language accepts strings like `"displayName=tokyo"`,
|
---|
| 189 | * and is documented in more detail in [AIP-160](https://google.aip.dev/160).
|
---|
| 190 | * @opt_param int pageSize The maximum number of results to return. If not set,
|
---|
| 191 | * the service selects a default.
|
---|
| 192 | * @opt_param string pageToken A page token received from the `next_page_token`
|
---|
| 193 | * field in the response. Send that page token to receive the subsequent page.
|
---|
| 194 | * @return ListLocationsResponse
|
---|
| 195 | * @throws \Google\Service\Exception
|
---|
| 196 | */
|
---|
| 197 | public function listProjectsLocations($name, $optParams = [])
|
---|
| 198 | {
|
---|
| 199 | $params = ['name' => $name];
|
---|
| 200 | $params = array_merge($params, $optParams);
|
---|
| 201 | return $this->call('list', [$params], ListLocationsResponse::class);
|
---|
| 202 | }
|
---|
| 203 | /**
|
---|
| 204 | * Romanize input text written in non-Latin scripts to Latin text.
|
---|
| 205 | * (locations.romanizeText)
|
---|
| 206 | *
|
---|
| 207 | * @param string $parent Required. Project or location to make a call. Must
|
---|
| 208 | * refer to a caller's project. Format: `projects/{project-number-or-
|
---|
| 209 | * id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global
|
---|
| 210 | * calls, use `projects/{project-number-or-id}/locations/global` or
|
---|
| 211 | * `projects/{project-number-or-id}`.
|
---|
| 212 | * @param RomanizeTextRequest $postBody
|
---|
| 213 | * @param array $optParams Optional parameters.
|
---|
| 214 | * @return RomanizeTextResponse
|
---|
| 215 | * @throws \Google\Service\Exception
|
---|
| 216 | */
|
---|
| 217 | public function romanizeText($parent, RomanizeTextRequest $postBody, $optParams = [])
|
---|
| 218 | {
|
---|
| 219 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 220 | $params = array_merge($params, $optParams);
|
---|
| 221 | return $this->call('romanizeText', [$params], RomanizeTextResponse::class);
|
---|
| 222 | }
|
---|
| 223 | /**
|
---|
| 224 | * Translates documents in synchronous mode. (locations.translateDocument)
|
---|
| 225 | *
|
---|
| 226 | * @param string $parent Required. Location to make a regional call. Format:
|
---|
| 227 | * `projects/{project-number-or-id}/locations/{location-id}`. For global calls,
|
---|
| 228 | * use `projects/{project-number-or-id}/locations/global` or `projects/{project-
|
---|
| 229 | * number-or-id}`. Non-global location is required for requests using AutoML
|
---|
| 230 | * models or custom glossaries. Models and glossaries must be within the same
|
---|
| 231 | * region (have the same location-id), otherwise an INVALID_ARGUMENT (400) error
|
---|
| 232 | * is returned.
|
---|
| 233 | * @param TranslateDocumentRequest $postBody
|
---|
| 234 | * @param array $optParams Optional parameters.
|
---|
| 235 | * @return TranslateDocumentResponse
|
---|
| 236 | * @throws \Google\Service\Exception
|
---|
| 237 | */
|
---|
| 238 | public function translateDocument($parent, TranslateDocumentRequest $postBody, $optParams = [])
|
---|
| 239 | {
|
---|
| 240 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 241 | $params = array_merge($params, $optParams);
|
---|
| 242 | return $this->call('translateDocument', [$params], TranslateDocumentResponse::class);
|
---|
| 243 | }
|
---|
| 244 | /**
|
---|
| 245 | * Translates input text and returns translated text. (locations.translateText)
|
---|
| 246 | *
|
---|
| 247 | * @param string $parent Required. Project or location to make a call. Must
|
---|
| 248 | * refer to a caller's project. Format: `projects/{project-number-or-id}` or
|
---|
| 249 | * `projects/{project-number-or-id}/locations/{location-id}`. For global calls,
|
---|
| 250 | * use `projects/{project-number-or-id}/locations/global` or `projects/{project-
|
---|
| 251 | * number-or-id}`. Non-global location is required for requests using AutoML
|
---|
| 252 | * models or custom glossaries. Models and glossaries must be within the same
|
---|
| 253 | * region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is
|
---|
| 254 | * returned.
|
---|
| 255 | * @param TranslateTextRequest $postBody
|
---|
| 256 | * @param array $optParams Optional parameters.
|
---|
| 257 | * @return TranslateTextResponse
|
---|
| 258 | * @throws \Google\Service\Exception
|
---|
| 259 | */
|
---|
| 260 | public function translateText($parent, TranslateTextRequest $postBody, $optParams = [])
|
---|
| 261 | {
|
---|
| 262 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 263 | $params = array_merge($params, $optParams);
|
---|
| 264 | return $this->call('translateText', [$params], TranslateTextResponse::class);
|
---|
| 265 | }
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 269 | class_alias(ProjectsLocations::class, 'Google_Service_Translate_Resource_ProjectsLocations');
|
---|