Skip to content

Commit 6da9037

Browse files
authored
Merge pull request #1209 from watson-developer-cloud/fix-lt
fix(language-translator-v3): add content-type to createModelOptions model properties
2 parents 8ed1a54 + df913a6 commit 6da9037

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2019, 2021.
2+
* (C) Copyright IBM Corp. 2019, 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -12,7 +12,7 @@
1212
*/
1313

1414
/*
15-
* IBM OpenAPI SDK Code Generator Version: 3.38.0-07189efd-20210827-205025
15+
* IBM OpenAPI SDK Code Generator Version: 3.46.0-a4e29da0-20220224-210428
1616
*/
1717

1818
package com.ibm.watson.language_translator.v3;
@@ -440,13 +440,13 @@ public ServiceCall<TranslationModel> createModel(CreateModelOptions createModelO
440440
if (createModelOptions.forcedGlossary() != null) {
441441
okhttp3.RequestBody forcedGlossaryBody =
442442
RequestUtils.inputStreamBody(
443-
createModelOptions.forcedGlossary(), "application/octet-stream");
443+
createModelOptions.forcedGlossary(), createModelOptions.forcedGlossaryContentType());
444444
multipartBuilder.addFormDataPart("forced_glossary", "filename", forcedGlossaryBody);
445445
}
446446
if (createModelOptions.parallelCorpus() != null) {
447447
okhttp3.RequestBody parallelCorpusBody =
448448
RequestUtils.inputStreamBody(
449-
createModelOptions.parallelCorpus(), "application/octet-stream");
449+
createModelOptions.parallelCorpus(), createModelOptions.parallelCorpusContentType());
450450
multipartBuilder.addFormDataPart("parallel_corpus", "filename", parallelCorpusBody);
451451
}
452452
builder.body(multipartBuilder.build());

language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2018, 2020.
2+
* (C) Copyright IBM Corp. 2018, 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -23,20 +23,26 @@ public class CreateModelOptions extends GenericModel {
2323

2424
protected String baseModelId;
2525
protected InputStream forcedGlossary;
26+
protected String forcedGlossaryContentType;
2627
protected InputStream parallelCorpus;
28+
protected String parallelCorpusContentType;
2729
protected String name;
2830

2931
/** Builder. */
3032
public static class Builder {
3133
private String baseModelId;
3234
private InputStream forcedGlossary;
35+
private String forcedGlossaryContentType;
3336
private InputStream parallelCorpus;
37+
private String parallelCorpusContentType;
3438
private String name;
3539

3640
private Builder(CreateModelOptions createModelOptions) {
3741
this.baseModelId = createModelOptions.baseModelId;
3842
this.forcedGlossary = createModelOptions.forcedGlossary;
43+
this.forcedGlossaryContentType = createModelOptions.forcedGlossaryContentType;
3944
this.parallelCorpus = createModelOptions.parallelCorpus;
45+
this.parallelCorpusContentType = createModelOptions.parallelCorpusContentType;
4046
this.name = createModelOptions.name;
4147
}
4248

@@ -83,6 +89,17 @@ public Builder forcedGlossary(InputStream forcedGlossary) {
8389
return this;
8490
}
8591

92+
/**
93+
* Set the forcedGlossaryContentType.
94+
*
95+
* @param forcedGlossaryContentType the forcedGlossaryContentType
96+
* @return the CreateModelOptions builder
97+
*/
98+
public Builder forcedGlossaryContentType(String forcedGlossaryContentType) {
99+
this.forcedGlossaryContentType = forcedGlossaryContentType;
100+
return this;
101+
}
102+
86103
/**
87104
* Set the parallelCorpus.
88105
*
@@ -94,6 +111,17 @@ public Builder parallelCorpus(InputStream parallelCorpus) {
94111
return this;
95112
}
96113

114+
/**
115+
* Set the parallelCorpusContentType.
116+
*
117+
* @param parallelCorpusContentType the parallelCorpusContentType
118+
* @return the CreateModelOptions builder
119+
*/
120+
public Builder parallelCorpusContentType(String parallelCorpusContentType) {
121+
this.parallelCorpusContentType = parallelCorpusContentType;
122+
return this;
123+
}
124+
97125
/**
98126
* Set the name.
99127
*
@@ -135,7 +163,9 @@ protected CreateModelOptions(Builder builder) {
135163
builder.baseModelId, "baseModelId cannot be null");
136164
baseModelId = builder.baseModelId;
137165
forcedGlossary = builder.forcedGlossary;
166+
forcedGlossaryContentType = builder.forcedGlossaryContentType;
138167
parallelCorpus = builder.parallelCorpus;
168+
parallelCorpusContentType = builder.parallelCorpusContentType;
139169
name = builder.name;
140170
}
141171

@@ -181,6 +211,18 @@ public InputStream forcedGlossary() {
181211
return forcedGlossary;
182212
}
183213

214+
/**
215+
* Gets the forcedGlossaryContentType.
216+
*
217+
* <p>The content type of forcedGlossary. Values for this parameter can be obtained from the
218+
* HttpMediaType class.
219+
*
220+
* @return the forcedGlossaryContentType
221+
*/
222+
public String forcedGlossaryContentType() {
223+
return forcedGlossaryContentType;
224+
}
225+
184226
/**
185227
* Gets the parallelCorpus.
186228
*
@@ -201,6 +243,18 @@ public InputStream parallelCorpus() {
201243
return parallelCorpus;
202244
}
203245

246+
/**
247+
* Gets the parallelCorpusContentType.
248+
*
249+
* <p>The content type of parallelCorpus. Values for this parameter can be obtained from the
250+
* HttpMediaType class.
251+
*
252+
* @return the parallelCorpusContentType
253+
*/
254+
public String parallelCorpusContentType() {
255+
return parallelCorpusContentType;
256+
}
257+
204258
/**
205259
* Gets the name.
206260
*

language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ public void testCreateModelWOptions() throws Throwable {
355355
new CreateModelOptions.Builder()
356356
.baseModelId("testString")
357357
.forcedGlossary(TestUtilities.createMockStream("This is a mock file."))
358+
.forcedGlossaryContentType("application/x-tmx+xml")
358359
.parallelCorpus(TestUtilities.createMockStream("This is a mock file."))
360+
.parallelCorpusContentType("application/x-tmx+xml")
359361
.name("testString")
360362
.build();
361363

language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/CreateModelOptionsTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2020.
2+
* (C) Copyright IBM Corp. 2020, 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -35,16 +35,20 @@ public void testCreateModelOptions() throws Throwable {
3535
new CreateModelOptions.Builder()
3636
.baseModelId("testString")
3737
.forcedGlossary(TestUtilities.createMockStream("This is a mock file."))
38+
.forcedGlossaryContentType("application/x-tmx+xml")
3839
.parallelCorpus(TestUtilities.createMockStream("This is a mock file."))
40+
.parallelCorpusContentType("application/x-tmx+xml")
3941
.name("testString")
4042
.build();
4143
assertEquals(createModelOptionsModel.baseModelId(), "testString");
4244
assertEquals(
4345
IOUtils.toString(createModelOptionsModel.forcedGlossary()),
4446
IOUtils.toString(TestUtilities.createMockStream("This is a mock file.")));
47+
assertEquals(createModelOptionsModel.forcedGlossaryContentType(), "application/x-tmx+xml");
4548
assertEquals(
4649
IOUtils.toString(createModelOptionsModel.parallelCorpus()),
4750
IOUtils.toString(TestUtilities.createMockStream("This is a mock file.")));
51+
assertEquals(createModelOptionsModel.parallelCorpusContentType(), "application/x-tmx+xml");
4852
assertEquals(createModelOptionsModel.name(), "testString");
4953
}
5054

0 commit comments

Comments
 (0)