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
18namespace Google\Service\Translate\Resource;
19
20use Google\Service\Translate\BatchTranslateDocumentRequest;
21use Google\Service\Translate\BatchTranslateTextRequest;
22use Google\Service\Translate\DetectLanguageRequest;
23use Google\Service\Translate\DetectLanguageResponse;
24use Google\Service\Translate\ListLocationsResponse;
25use Google\Service\Translate\Location;
26use Google\Service\Translate\Operation;
27use Google\Service\Translate\SupportedLanguages;
28use Google\Service\Translate\TranslateDocumentRequest;
29use Google\Service\Translate\TranslateDocumentResponse;
30use Google\Service\Translate\TranslateTextRequest;
31use Google\Service\Translate\TranslateTextResponse;
32
33/**
34 * The "locations" collection of methods.
35 * Typical usage is:
36 *  <code>
37 *   $translateService = new Google\Service\Translate(...);
38 *   $locations = $translateService->locations;
39 *  </code>
40 */
41class ProjectsLocations extends \Google\Service\Resource
42{
43  /**
44   * Translates a large volume of document in asynchronous batch mode. This
45   * function provides real-time output as the inputs are being processed. If
46   * caller cancels a request, the partial results (for an input file, it's all or
47   * nothing) may still be available on the specified output location. This call
48   * returns immediately and you can use google.longrunning.Operation.name to poll
49   * the status of the call. (locations.batchTranslateDocument)
50   *
51   * @param string $parent Required. Location to make a regional call. Format:
52   * `projects/{project-number-or-id}/locations/{location-id}`. The `global`
53   * location is not supported for batch translation. Only AutoML Translation
54   * models or glossaries within the same region (have the same location-id) can
55   * be used, otherwise an INVALID_ARGUMENT (400) error is returned.
56   * @param BatchTranslateDocumentRequest $postBody
57   * @param array $optParams Optional parameters.
58   * @return Operation
59   */
60  public function batchTranslateDocument($parent, BatchTranslateDocumentRequest $postBody, $optParams = [])
61  {
62    $params = ['parent' => $parent, 'postBody' => $postBody];
63    $params = array_merge($params, $optParams);
64    return $this->call('batchTranslateDocument', [$params], Operation::class);
65  }
66  /**
67   * Translates a large volume of text in asynchronous batch mode. This function
68   * provides real-time output as the inputs are being processed. If caller
69   * cancels a request, the partial results (for an input file, it's all or
70   * nothing) may still be available on the specified output location. This call
71   * returns immediately and you can use google.longrunning.Operation.name to poll
72   * the status of the call. (locations.batchTranslateText)
73   *
74   * @param string $parent Required. Location to make a call. Must refer to a
75   * caller's project. Format: `projects/{project-number-or-id}/locations
76   * /{location-id}`. The `global` location is not supported for batch
77   * translation. Only AutoML Translation models or glossaries within the same
78   * region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT
79   * (400) error is returned.
80   * @param BatchTranslateTextRequest $postBody
81   * @param array $optParams Optional parameters.
82   * @return Operation
83   */
84  public function batchTranslateText($parent, BatchTranslateTextRequest $postBody, $optParams = [])
85  {
86    $params = ['parent' => $parent, 'postBody' => $postBody];
87    $params = array_merge($params, $optParams);
88    return $this->call('batchTranslateText', [$params], Operation::class);
89  }
90  /**
91   * Detects the language of text within a request. (locations.detectLanguage)
92   *
93   * @param string $parent Required. Project or location to make a call. Must
94   * refer to a caller's project. Format: `projects/{project-number-or-
95   * id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global
96   * calls, use `projects/{project-number-or-id}/locations/global` or `projects
97   * /{project-number-or-id}`. Only models within the same region (has same
98   * location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is
99   * returned.
100   * @param DetectLanguageRequest $postBody
101   * @param array $optParams Optional parameters.
102   * @return DetectLanguageResponse
103   */
104  public function detectLanguage($parent, DetectLanguageRequest $postBody, $optParams = [])
105  {
106    $params = ['parent' => $parent, 'postBody' => $postBody];
107    $params = array_merge($params, $optParams);
108    return $this->call('detectLanguage', [$params], DetectLanguageResponse::class);
109  }
110  /**
111   * Gets information about a location. (locations.get)
112   *
113   * @param string $name Resource name for the location.
114   * @param array $optParams Optional parameters.
115   * @return Location
116   */
117  public function get($name, $optParams = [])
118  {
119    $params = ['name' => $name];
120    $params = array_merge($params, $optParams);
121    return $this->call('get', [$params], Location::class);
122  }
123  /**
124   * Returns a list of supported languages for translation.
125   * (locations.getSupportedLanguages)
126   *
127   * @param string $parent Required. Project or location to make a call. Must
128   * refer to a caller's project. Format: `projects/{project-number-or-id}` or
129   * `projects/{project-number-or-id}/locations/{location-id}`. For global calls,
130   * use `projects/{project-number-or-id}/locations/global` or `projects/{project-
131   * number-or-id}`. Non-global location is required for AutoML models. Only
132   * models within the same region (have same location-id) can be used, otherwise
133   * an INVALID_ARGUMENT (400) error is returned.
134   * @param array $optParams Optional parameters.
135   *
136   * @opt_param string displayLanguageCode Optional. The language to use to return
137   * localized, human readable names of supported languages. If missing, then
138   * display names are not returned in a response.
139   * @opt_param string model Optional. Get supported languages of this model. The
140   * format depends on model type: - AutoML Translation models: `projects
141   * /{project-number-or-id}/locations/{location-id}/models/{model-id}` - General
142   * (built-in) models: `projects/{project-number-or-id}/locations/{location-
143   * id}/models/general/nmt`, Returns languages supported by the specified model.
144   * If missing, we get supported languages of Google general NMT model.
145   * @return SupportedLanguages
146   */
147  public function getSupportedLanguages($parent, $optParams = [])
148  {
149    $params = ['parent' => $parent];
150    $params = array_merge($params, $optParams);
151    return $this->call('getSupportedLanguages', [$params], SupportedLanguages::class);
152  }
153  /**
154   * Lists information about the supported locations for this service.
155   * (locations.listProjectsLocations)
156   *
157   * @param string $name The resource that owns the locations collection, if
158   * applicable.
159   * @param array $optParams Optional parameters.
160   *
161   * @opt_param string filter A filter to narrow down results to a preferred
162   * subset. The filtering language accepts strings like `"displayName=tokyo"`,
163   * and is documented in more detail in [AIP-160](https://google.aip.dev/160).
164   * @opt_param int pageSize The maximum number of results to return. If not set,
165   * the service selects a default.
166   * @opt_param string pageToken A page token received from the `next_page_token`
167   * field in the response. Send that page token to receive the subsequent page.
168   * @return ListLocationsResponse
169   */
170  public function listProjectsLocations($name, $optParams = [])
171  {
172    $params = ['name' => $name];
173    $params = array_merge($params, $optParams);
174    return $this->call('list', [$params], ListLocationsResponse::class);
175  }
176  /**
177   * Translates documents in synchronous mode. (locations.translateDocument)
178   *
179   * @param string $parent Required. Location to make a regional call. Format:
180   * `projects/{project-number-or-id}/locations/{location-id}`. For global calls,
181   * use `projects/{project-number-or-id}/locations/global` or `projects/{project-
182   * number-or-id}`. Non-global location is required for requests using AutoML
183   * models or custom glossaries. Models and glossaries must be within the same
184   * region (have the same location-id), otherwise an INVALID_ARGUMENT (400) error
185   * is returned.
186   * @param TranslateDocumentRequest $postBody
187   * @param array $optParams Optional parameters.
188   * @return TranslateDocumentResponse
189   */
190  public function translateDocument($parent, TranslateDocumentRequest $postBody, $optParams = [])
191  {
192    $params = ['parent' => $parent, 'postBody' => $postBody];
193    $params = array_merge($params, $optParams);
194    return $this->call('translateDocument', [$params], TranslateDocumentResponse::class);
195  }
196  /**
197   * Translates input text and returns translated text. (locations.translateText)
198   *
199   * @param string $parent Required. Project or location to make a call. Must
200   * refer to a caller's project. Format: `projects/{project-number-or-id}` or
201   * `projects/{project-number-or-id}/locations/{location-id}`. For global calls,
202   * use `projects/{project-number-or-id}/locations/global` or `projects/{project-
203   * number-or-id}`. Non-global location is required for requests using AutoML
204   * models or custom glossaries. Models and glossaries must be within the same
205   * region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is
206   * returned.
207   * @param TranslateTextRequest $postBody
208   * @param array $optParams Optional parameters.
209   * @return TranslateTextResponse
210   */
211  public function translateText($parent, TranslateTextRequest $postBody, $optParams = [])
212  {
213    $params = ['parent' => $parent, 'postBody' => $postBody];
214    $params = array_merge($params, $optParams);
215    return $this->call('translateText', [$params], TranslateTextResponse::class);
216  }
217}
218
219// Adding a class alias for backwards compatibility with the previous class name.
220class_alias(ProjectsLocations::class, 'Google_Service_Translate_Resource_ProjectsLocations');
221