Skip to content

Commit

Permalink
feat(client-translate): Added ListLanguages API which can be used to …
Browse files Browse the repository at this point in the history
…list the languages supported by Translate.
  • Loading branch information
awstools committed Jun 29, 2022
1 parent fea922c commit 4ec076d
Show file tree
Hide file tree
Showing 10 changed files with 732 additions and 71 deletions.
53 changes: 45 additions & 8 deletions clients/client-translate/src/Translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import {
ImportTerminologyCommandInput,
ImportTerminologyCommandOutput,
} from "./commands/ImportTerminologyCommand";
import {
ListLanguagesCommand,
ListLanguagesCommandInput,
ListLanguagesCommandOutput,
} from "./commands/ListLanguagesCommand";
import {
ListParallelDataCommand,
ListParallelDataCommandInput,
Expand Down Expand Up @@ -275,14 +280,14 @@ export class Translate extends TranslateClient {
}

/**
* <p>Creates or updates a custom terminology, depending on whether or not one already exists
* for the given terminology name. Importing a terminology with the same name as an existing one
* will merge the terminologies based on the chosen merge strategy. Currently, the only supported
* merge strategy is OVERWRITE, and so the imported terminology will overwrite an existing
* terminology of the same name.</p>
* <p>If you import a terminology that overwrites an existing one, the new terminology take up
* to 10 minutes to fully propagate and be available for use in a translation due to cache
* policies with the DataPlane service that performs the translations.</p>
* <p>Creates or updates a custom terminology, depending on whether one already exists for the
* given terminology name. Importing a terminology with the same name as an existing one will
* merge the terminologies based on the chosen merge strategy. The only supported merge strategy
* is OVERWRITE, where the imported terminology overwrites the existing terminology of the same
* name.</p>
* <p>If you import a terminology that overwrites an existing one, the new terminology takes up
* to 10 minutes to fully propagate. After that, translations have access to the new
* terminology.</p>
*/
public importTerminology(
args: ImportTerminologyCommandInput,
Expand Down Expand Up @@ -313,6 +318,38 @@ export class Translate extends TranslateClient {
}
}

/**
* <p>Provides a list of languages (RFC-5646 codes and names) that Amazon Translate supports.</p>
*/
public listLanguages(
args: ListLanguagesCommandInput,
options?: __HttpHandlerOptions
): Promise<ListLanguagesCommandOutput>;
public listLanguages(
args: ListLanguagesCommandInput,
cb: (err: any, data?: ListLanguagesCommandOutput) => void
): void;
public listLanguages(
args: ListLanguagesCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: ListLanguagesCommandOutput) => void
): void;
public listLanguages(
args: ListLanguagesCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListLanguagesCommandOutput) => void),
cb?: (err: any, data?: ListLanguagesCommandOutput) => void
): Promise<ListLanguagesCommandOutput> | void {
const command = new ListLanguagesCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Provides a list of your parallel data resources in Amazon Translate.</p>
*/
Expand Down
3 changes: 3 additions & 0 deletions clients/client-translate/src/TranslateClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
import { GetParallelDataCommandInput, GetParallelDataCommandOutput } from "./commands/GetParallelDataCommand";
import { GetTerminologyCommandInput, GetTerminologyCommandOutput } from "./commands/GetTerminologyCommand";
import { ImportTerminologyCommandInput, ImportTerminologyCommandOutput } from "./commands/ImportTerminologyCommand";
import { ListLanguagesCommandInput, ListLanguagesCommandOutput } from "./commands/ListLanguagesCommand";
import { ListParallelDataCommandInput, ListParallelDataCommandOutput } from "./commands/ListParallelDataCommand";
import { ListTerminologiesCommandInput, ListTerminologiesCommandOutput } from "./commands/ListTerminologiesCommand";
import {
Expand All @@ -89,6 +90,7 @@ export type ServiceInputTypes =
| GetParallelDataCommandInput
| GetTerminologyCommandInput
| ImportTerminologyCommandInput
| ListLanguagesCommandInput
| ListParallelDataCommandInput
| ListTerminologiesCommandInput
| ListTextTranslationJobsCommandInput
Expand All @@ -105,6 +107,7 @@ export type ServiceOutputTypes =
| GetParallelDataCommandOutput
| GetTerminologyCommandOutput
| ImportTerminologyCommandOutput
| ListLanguagesCommandOutput
| ListParallelDataCommandOutput
| ListTerminologiesCommandOutput
| ListTextTranslationJobsCommandOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export interface ImportTerminologyCommandInput extends ImportTerminologyRequest
export interface ImportTerminologyCommandOutput extends ImportTerminologyResponse, __MetadataBearer {}

/**
* <p>Creates or updates a custom terminology, depending on whether or not one already exists
* for the given terminology name. Importing a terminology with the same name as an existing one
* will merge the terminologies based on the chosen merge strategy. Currently, the only supported
* merge strategy is OVERWRITE, and so the imported terminology will overwrite an existing
* terminology of the same name.</p>
* <p>If you import a terminology that overwrites an existing one, the new terminology take up
* to 10 minutes to fully propagate and be available for use in a translation due to cache
* policies with the DataPlane service that performs the translations.</p>
* <p>Creates or updates a custom terminology, depending on whether one already exists for the
* given terminology name. Importing a terminology with the same name as an existing one will
* merge the terminologies based on the chosen merge strategy. The only supported merge strategy
* is OVERWRITE, where the imported terminology overwrites the existing terminology of the same
* name.</p>
* <p>If you import a terminology that overwrites an existing one, the new terminology takes up
* to 10 minutes to fully propagate. After that, translations have access to the new
* terminology.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
96 changes: 96 additions & 0 deletions clients/client-translate/src/commands/ListLanguagesCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { ListLanguagesRequest, ListLanguagesResponse } from "../models/models_0";
import {
deserializeAws_json1_1ListLanguagesCommand,
serializeAws_json1_1ListLanguagesCommand,
} from "../protocols/Aws_json1_1";
import { ServiceInputTypes, ServiceOutputTypes, TranslateClientResolvedConfig } from "../TranslateClient";

export interface ListLanguagesCommandInput extends ListLanguagesRequest {}
export interface ListLanguagesCommandOutput extends ListLanguagesResponse, __MetadataBearer {}

/**
* <p>Provides a list of languages (RFC-5646 codes and names) that Amazon Translate supports.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { TranslateClient, ListLanguagesCommand } from "@aws-sdk/client-translate"; // ES Modules import
* // const { TranslateClient, ListLanguagesCommand } = require("@aws-sdk/client-translate"); // CommonJS import
* const client = new TranslateClient(config);
* const command = new ListLanguagesCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link ListLanguagesCommandInput} for command's `input` shape.
* @see {@link ListLanguagesCommandOutput} for command's `response` shape.
* @see {@link TranslateClientResolvedConfig | config} for TranslateClient's `config` shape.
*
*/
export class ListLanguagesCommand extends $Command<
ListLanguagesCommandInput,
ListLanguagesCommandOutput,
TranslateClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: ListLanguagesCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: TranslateClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<ListLanguagesCommandInput, ListLanguagesCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "TranslateClient";
const commandName = "ListLanguagesCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: ListLanguagesRequest.filterSensitiveLog,
outputFilterSensitiveLog: ListLanguagesResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: ListLanguagesCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_json1_1ListLanguagesCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListLanguagesCommandOutput> {
return deserializeAws_json1_1ListLanguagesCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
1 change: 1 addition & 0 deletions clients/client-translate/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from "./DescribeTextTranslationJobCommand";
export * from "./GetParallelDataCommand";
export * from "./GetTerminologyCommand";
export * from "./ImportTerminologyCommand";
export * from "./ListLanguagesCommand";
export * from "./ListParallelDataCommand";
export * from "./ListTerminologiesCommand";
export * from "./ListTextTranslationJobsCommand";
Expand Down
Loading

0 comments on commit 4ec076d

Please sign in to comment.