in aws-android-sdk-transcribe/src/main/java/com/amazonaws/services/transcribe/model/transform/StartTranscriptionJobRequestMarshaller.java [46:212]
public Request<StartTranscriptionJobRequest> marshall(
StartTranscriptionJobRequest startTranscriptionJobRequest) {
if (startTranscriptionJobRequest == null) {
throw new AmazonClientException(
"Invalid argument passed to marshall(StartTranscriptionJobRequest)");
}
Request<StartTranscriptionJobRequest> request = new DefaultRequest<StartTranscriptionJobRequest>(
startTranscriptionJobRequest, "AmazonTranscribe");
String target = "Transcribe.StartTranscriptionJob";
request.addHeader("X-Amz-Target", target);
request.setHttpMethod(HttpMethodName.POST);
String uriResourcePath = "/";
request.setResourcePath(uriResourcePath);
try {
StringWriter stringWriter = new StringWriter();
AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);
jsonWriter.beginObject();
if (startTranscriptionJobRequest.getTranscriptionJobName() != null) {
String transcriptionJobName = startTranscriptionJobRequest
.getTranscriptionJobName();
jsonWriter.name("TranscriptionJobName");
jsonWriter.value(transcriptionJobName);
}
if (startTranscriptionJobRequest.getLanguageCode() != null) {
String languageCode = startTranscriptionJobRequest.getLanguageCode();
jsonWriter.name("LanguageCode");
jsonWriter.value(languageCode);
}
if (startTranscriptionJobRequest.getMediaSampleRateHertz() != null) {
Integer mediaSampleRateHertz = startTranscriptionJobRequest
.getMediaSampleRateHertz();
jsonWriter.name("MediaSampleRateHertz");
jsonWriter.value(mediaSampleRateHertz);
}
if (startTranscriptionJobRequest.getMediaFormat() != null) {
String mediaFormat = startTranscriptionJobRequest.getMediaFormat();
jsonWriter.name("MediaFormat");
jsonWriter.value(mediaFormat);
}
if (startTranscriptionJobRequest.getMedia() != null) {
Media media = startTranscriptionJobRequest.getMedia();
jsonWriter.name("Media");
MediaJsonMarshaller.getInstance().marshall(media, jsonWriter);
}
if (startTranscriptionJobRequest.getOutputBucketName() != null) {
String outputBucketName = startTranscriptionJobRequest.getOutputBucketName();
jsonWriter.name("OutputBucketName");
jsonWriter.value(outputBucketName);
}
if (startTranscriptionJobRequest.getOutputKey() != null) {
String outputKey = startTranscriptionJobRequest.getOutputKey();
jsonWriter.name("OutputKey");
jsonWriter.value(outputKey);
}
if (startTranscriptionJobRequest.getOutputEncryptionKMSKeyId() != null) {
String outputEncryptionKMSKeyId = startTranscriptionJobRequest
.getOutputEncryptionKMSKeyId();
jsonWriter.name("OutputEncryptionKMSKeyId");
jsonWriter.value(outputEncryptionKMSKeyId);
}
if (startTranscriptionJobRequest.getKMSEncryptionContext() != null) {
java.util.Map<String, String> kMSEncryptionContext = startTranscriptionJobRequest
.getKMSEncryptionContext();
jsonWriter.name("KMSEncryptionContext");
jsonWriter.beginObject();
for (java.util.Map.Entry<String, String> kMSEncryptionContextEntry : kMSEncryptionContext
.entrySet()) {
String kMSEncryptionContextValue = kMSEncryptionContextEntry.getValue();
if (kMSEncryptionContextValue != null) {
jsonWriter.name(kMSEncryptionContextEntry.getKey());
jsonWriter.value(kMSEncryptionContextValue);
}
}
jsonWriter.endObject();
}
if (startTranscriptionJobRequest.getSettings() != null) {
Settings settings = startTranscriptionJobRequest.getSettings();
jsonWriter.name("Settings");
SettingsJsonMarshaller.getInstance().marshall(settings, jsonWriter);
}
if (startTranscriptionJobRequest.getModelSettings() != null) {
ModelSettings modelSettings = startTranscriptionJobRequest.getModelSettings();
jsonWriter.name("ModelSettings");
ModelSettingsJsonMarshaller.getInstance().marshall(modelSettings, jsonWriter);
}
if (startTranscriptionJobRequest.getJobExecutionSettings() != null) {
JobExecutionSettings jobExecutionSettings = startTranscriptionJobRequest
.getJobExecutionSettings();
jsonWriter.name("JobExecutionSettings");
JobExecutionSettingsJsonMarshaller.getInstance().marshall(jobExecutionSettings,
jsonWriter);
}
if (startTranscriptionJobRequest.getContentRedaction() != null) {
ContentRedaction contentRedaction = startTranscriptionJobRequest
.getContentRedaction();
jsonWriter.name("ContentRedaction");
ContentRedactionJsonMarshaller.getInstance().marshall(contentRedaction, jsonWriter);
}
if (startTranscriptionJobRequest.getIdentifyLanguage() != null) {
Boolean identifyLanguage = startTranscriptionJobRequest.getIdentifyLanguage();
jsonWriter.name("IdentifyLanguage");
jsonWriter.value(identifyLanguage);
}
if (startTranscriptionJobRequest.getLanguageOptions() != null) {
java.util.List<String> languageOptions = startTranscriptionJobRequest
.getLanguageOptions();
jsonWriter.name("LanguageOptions");
jsonWriter.beginArray();
for (String languageOptionsItem : languageOptions) {
if (languageOptionsItem != null) {
jsonWriter.value(languageOptionsItem);
}
}
jsonWriter.endArray();
}
if (startTranscriptionJobRequest.getSubtitles() != null) {
Subtitles subtitles = startTranscriptionJobRequest.getSubtitles();
jsonWriter.name("Subtitles");
SubtitlesJsonMarshaller.getInstance().marshall(subtitles, jsonWriter);
}
if (startTranscriptionJobRequest.getTags() != null) {
java.util.List<Tag> tags = startTranscriptionJobRequest.getTags();
jsonWriter.name("Tags");
jsonWriter.beginArray();
for (Tag tagsItem : tags) {
if (tagsItem != null) {
TagJsonMarshaller.getInstance().marshall(tagsItem, jsonWriter);
}
}
jsonWriter.endArray();
}
if (startTranscriptionJobRequest.getLanguageIdSettings() != null) {
java.util.Map<String, LanguageIdSettings> languageIdSettings = startTranscriptionJobRequest
.getLanguageIdSettings();
jsonWriter.name("LanguageIdSettings");
jsonWriter.beginObject();
for (java.util.Map.Entry<String, LanguageIdSettings> languageIdSettingsEntry : languageIdSettings
.entrySet()) {
LanguageIdSettings languageIdSettingsValue = languageIdSettingsEntry.getValue();
if (languageIdSettingsValue != null) {
jsonWriter.name(languageIdSettingsEntry.getKey());
LanguageIdSettingsJsonMarshaller.getInstance().marshall(
languageIdSettingsValue, jsonWriter);
}
}
jsonWriter.endObject();
}
jsonWriter.endObject();
jsonWriter.close();
String snippet = stringWriter.toString();
byte[] content = snippet.getBytes(UTF8);
request.setContent(new StringInputStream(snippet));
request.addHeader("Content-Length", Integer.toString(content.length));
} catch (Throwable t) {
throw new AmazonClientException(
"Unable to marshall request to JSON: " + t.getMessage(), t);
}
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/x-amz-json-1.1");
}
return request;
}