ExAws.Translate (ExAws.Translate v0.3.0) View Source
The ExAws.Translate library provides an Elixir API for accessing the AWS Translate APIs. Please refer to the AWS Translate API Documentation for the list of functionalities and available actions.
Link to this section Summary
Functions
A synchronous action that deletes a custom terminology.
Gets the properties associated with an asycnhronous batch translation job including name, ID, status, source and target languages, input/output S3 buckets, and so on.
Retrieves a custom terminology.
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.
Provides a list of custom terminologies associated with your account.
Gets a list of the batch translation jobs that you have submitted.
Starts an asynchronous batch translation job. Batch translation jobs can be used to translate large volumes of text across multiple documents at once. For more information, see Asynchronous Batch Processing.
Stops an asynchronous batch translation job that is in progress.
Translates a phrase from the source language to the target language.
Link to this section Types
Specs
Specs
Specs
Specs
list_text_translation_opts() :: [ filter: text_translation_job_filter(), max_results: integer(), next_token: String.t() ]
Specs
output_data_config() :: %{s3_uri: String.t()}
Specs
Specs
Specs
Specs
translate_text_opts() :: [{:terminology_names, String.t()}]
Link to this section Functions
Specs
delete_terminology(name :: String.t()) :: ExAws.Operation.JSON.t()
A synchronous action that deletes a custom terminology.
Examples
iex> ExAws.Translate.delete_terminology("terminology") |> ExAws.request()
{:ok, %{}}
For more information visit the AWS Translate API Documentation for DeleteTerminology.
Specs
describe_text_translation_job(job_id :: String.t()) :: ExAws.Operation.JSON.t()
Gets the properties associated with an asycnhronous batch translation job including name, ID, status, source and target languages, input/output S3 buckets, and so on.
Examples
iex> iex(2)> ExAws.Translate.describe_text_translation_job("12345") |> ExAws.request()
{:ok,
%{
"TextTranslationJobProperties" => %{
"DataAccessRoleArn" => "arn:aws:iam::123456789123:role/service-role/AmazonTranslateServiceRole-translate",
"EndTime" => 1592240282.932,
"InputDataConfig" => %{
"ContentType" => "text/plain",
"S3Uri" => "s3://bucket/input/"
},
"JobDetails" => %{
"DocumentsWithErrorsCount" => 0,
"InputDocumentsCount" => 1,
"TranslatedDocumentsCount" => 1
},
"JobId" => "12345",
"JobName" => "testjob",
"JobStatus" => "COMPLETED",
"Message" => "Your job has completed successfully.",
"OutputDataConfig" => %{
"S3Uri" => "s3://bucket/output/123456789123-TranslateText-12345/"
},
"SourceLanguageCode" => "en",
"SubmittedTime" => 1592239611.151,
"TargetLanguageCodes" => ["es"]
}
}
}
For more information visit the AWS Translate API Documentation for DescribeTextTranslationJob.
Specs
get_terminology(name :: String.t(), terminology_data_format :: String.t()) :: ExAws.Operation.JSON.t()
Retrieves a custom terminology.
Examples
iex> ExAws.Translate.get_terminology("terminology") |> ExAws.request()
{:ok,
%{
"TerminologyDataLocation" => %{
"Location" => "https://aws-translate-terminology-prod-us-east-1.s3.us-east-1.amazonaws.com/123456789123/TEST/LATEST/3953eeac-986d-41b3-a2d5-9d973ace34f1/CSV/terminology.csv?X-Amz-Security-Token=12345",
"RepositoryType" => "S3"
},
"TerminologyProperties" => %{
"Arn" => "arn:aws:translate:us-east-1:123456789123:terminology/TEST/LATEST",
"CreatedAt" => 1591997725.869,
"LastUpdatedAt" => 1591997725.869,
"Name" => "TEST",
"SizeBytes" => 24,
"SourceLanguageCode" => "en",
"TargetLanguageCodes" => ["fr"],
"TermCount" => 1
}
}
}
For more information visit the AWS Translate API Documentation for GetTerminology.
import_terminology(name, terminology_data, merge_strategy, opts \\ [])
View SourceSpecs
import_terminology( name :: String.t(), terminology_data :: terminology_data(), merge_strategy :: String.t(), opts :: import_terminology_opts() ) :: ExAws.Operation.JSON.t()
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.
Examples
iex> ExAws.Translate.import_terminology("terminology", %{file: "base64encodedbinary", format: "CSV"}, "OVERWRITE") |> ExAws.request()
{:ok,
%{
"TerminologyProperties" => %{
"Arn" => "arn:aws:translate:us-east-1:126427819807:terminology/terminology-test/LATEST",
"CreatedAt" => 1591997291.244,
"LastUpdatedAt" => 1591997291.244,
"Name" => "terminology-test",
"SizeBytes" => 24,
"SourceLanguageCode" => "en",
"TargetLanguageCodes" => ["fr"],
"TermCount" => 1
}
}
}
For more information visit the AWS Translate API Documentation for ImportTerminology.
Specs
list_terminologies(opts :: list_terminologies_opts()) :: ExAws.Operation.JSON.t()
Provides a list of custom terminologies associated with your account.
Examples
iex> ExAws.Translate.list_terminologies() |> ExAws.request()
{:ok,
%{
"TerminologyPropertiesList" => [
%{
"Arn" => "arn:aws:translate:us-east-1:126427819807:terminology/TEST/LATEST",
"CreatedAt" => 1591997725.869,
"LastUpdatedAt" => 1591997725.869,
"Name" => "terminology-test",
"SizeBytes" => 24,
"SourceLanguageCode" => "en",
"TargetLanguageCodes" => ["fr"],
"TermCount" => 1
}
]
}
}
For more information visit the AWS Translate API Documentation for ListTerminologies.
Specs
list_text_translation_jobs(opts :: list_text_translation_opts()) :: ExAws.Operation.JSON.t()
Gets a list of the batch translation jobs that you have submitted.
Examples
iex> ExAws.Translate.list_text_translation_jobs() |> ExAws.request()
{:ok,
%{
"TextTranslationJobPropertiesList" => [
%{
"DataAccessRoleArn" => "arn:aws:iam::123456789123:role/service-role/AmazonTranslateServiceRole-translate",
"EndTime" => 1592240282.932,
"InputDataConfig" => %{
"ContentType" => "text/plain",
"S3Uri" => "s3://bucket/input/"
},
"JobDetails" => %{
"DocumentsWithErrorsCount" => 0,
"InputDocumentsCount" => 1,
"TranslatedDocumentsCount" => 1
},
"JobId" => "12345",
"JobName" => "testjob",
"JobStatus" => "COMPLETED",
"Message" => "Your job has completed successfully.",
"OutputDataConfig" => %{
"S3Uri" => "s3://bucket/output/123456789123-TranslateText-12345/"
},
"SourceLanguageCode" => "en",
"SubmittedTime" => 1592239611.151,
"TargetLanguageCodes" => ["es"]
}
]
}
}
For more information visit the AWS Translate API Documentation for ListTestTranslationJobs.
start_text_translation_job(client_token, data_access_role_arn, input_data_config, output_data_config, source_language_code, target_language_codes, opts \\ [])
View SourceSpecs
start_text_translation_job( client_token :: String.t(), data_access_role_arn :: String.t(), input_data_config :: input_data_config(), output_data_config :: output_data_config(), source_language_code :: String.t(), target_language_codes :: list(), opts :: start_text_translation_job_opts() ) :: ExAws.Operation.JSON.t()
Starts an asynchronous batch translation job. Batch translation jobs can be used to translate large volumes of text across multiple documents at once. For more information, see Asynchronous Batch Processing.
Batch translation jobs can be described with the DescribeTextTranslationJob operation, listed with the ListTextTranslationJobs operation, and stopped with the StopTextTranslationJob operation.
Examples
iex> ExAws.Translate.start_text_translation_job(
"ba3e6b13-b79b-4c1c-97ca-7258d7545ec1",
"arn:aws:iam::123456789123:role/service-role/AmazonTranslateServiceRole-translate",
%{content_type: "text/plain", s3_uri: "s3://bucket/input"},
%{s3_uri: "s3://bucket/output"},
"en",
["es"]
)
|> ExAws.request()
{:ok,
%{"JobId" => "cc4208305119d3fff9a5e8daa702c637", "JobStatus" => "SUBMITTED"}}
For more information visit the AWS Translate API Documentation for StartTextTranslationJob.
Specs
stop_text_translation_job(job_id :: String.t()) :: ExAws.Operation.JSON.t()
Stops an asynchronous batch translation job that is in progress.
If the job's state is IN_PROGRESS, the job will be marked for termination and put into the STOP_REQUESTED state. If the job completes before it can be stopped, it is put into the COMPLETED state. Otherwise, the job is put into the STOPPED state.
Asynchronous batch translation jobs are started with the StartTextTranslationJob operation. You can use the DescribeTextTranslationJob or ListTextTranslationJobs operations to get a batch translation job's JobId
.
Examples
iex> ExAws.Translate.stop_text_translation_job("12345") |> ExAws.request() {:ok,
%{
"JobId" => "12345",
"JobStatus" => "STOP_REQUESTED"
}
}
For more information visit the AWS Translate API Documentation for StopTextTranslationJob.
translate_text(text, source_language_code, target_language_code, opts \\ [])
View SourceSpecs
translate_text( text :: String.t(), source_language_code :: String.t(), target_language_code :: String.t(), opts :: translate_text_opts() ) :: ExAws.Operation.JSON.t()
Translates a phrase from the source language to the target language.
Examples
iex> ExAws.Translate.translate_text("Hello, World!", "en", "es") |> ExAws.request()
{:ok,
%{
"SourceLanguageCode" => "en",
"TargetLanguageCode" => "es",
"TranslatedText" => "¡Hola, Mundo!"
}
}
For more information visit the AWS Translate API Documentation for TranslateText.