Skip to content

Commit ac17067

Browse files
committed
feat(Discovery v2): Add initial generation of service
1 parent 14fefbd commit ac17067

File tree

73 files changed

+8101
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+8101
-0
lines changed

discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java

+672
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2019.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.discovery.v2.model;
14+
15+
import java.io.File;
16+
import java.io.FileInputStream;
17+
import java.io.FileNotFoundException;
18+
import java.io.InputStream;
19+
20+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
21+
22+
/**
23+
* The addDocument options.
24+
*/
25+
public class AddDocumentOptions extends GenericModel {
26+
27+
private String projectId;
28+
private String collectionId;
29+
private InputStream file;
30+
private String filename;
31+
private String fileContentType;
32+
private String metadata;
33+
private Boolean xWatsonDiscoveryForce;
34+
35+
/**
36+
* Builder.
37+
*/
38+
public static class Builder {
39+
private String projectId;
40+
private String collectionId;
41+
private InputStream file;
42+
private String filename;
43+
private String fileContentType;
44+
private String metadata;
45+
private Boolean xWatsonDiscoveryForce;
46+
47+
private Builder(AddDocumentOptions addDocumentOptions) {
48+
this.projectId = addDocumentOptions.projectId;
49+
this.collectionId = addDocumentOptions.collectionId;
50+
this.file = addDocumentOptions.file;
51+
this.filename = addDocumentOptions.filename;
52+
this.fileContentType = addDocumentOptions.fileContentType;
53+
this.metadata = addDocumentOptions.metadata;
54+
this.xWatsonDiscoveryForce = addDocumentOptions.xWatsonDiscoveryForce;
55+
}
56+
57+
/**
58+
* Instantiates a new builder.
59+
*/
60+
public Builder() {
61+
}
62+
63+
/**
64+
* Instantiates a new builder with required properties.
65+
*
66+
* @param projectId the projectId
67+
* @param collectionId the collectionId
68+
*/
69+
public Builder(String projectId, String collectionId) {
70+
this.projectId = projectId;
71+
this.collectionId = collectionId;
72+
}
73+
74+
/**
75+
* Builds a AddDocumentOptions.
76+
*
77+
* @return the addDocumentOptions
78+
*/
79+
public AddDocumentOptions build() {
80+
return new AddDocumentOptions(this);
81+
}
82+
83+
/**
84+
* Set the projectId.
85+
*
86+
* @param projectId the projectId
87+
* @return the AddDocumentOptions builder
88+
*/
89+
public Builder projectId(String projectId) {
90+
this.projectId = projectId;
91+
return this;
92+
}
93+
94+
/**
95+
* Set the collectionId.
96+
*
97+
* @param collectionId the collectionId
98+
* @return the AddDocumentOptions builder
99+
*/
100+
public Builder collectionId(String collectionId) {
101+
this.collectionId = collectionId;
102+
return this;
103+
}
104+
105+
/**
106+
* Set the file.
107+
*
108+
* @param file the file
109+
* @return the AddDocumentOptions builder
110+
*/
111+
public Builder file(InputStream file) {
112+
this.file = file;
113+
return this;
114+
}
115+
116+
/**
117+
* Set the filename.
118+
*
119+
* @param filename the filename
120+
* @return the AddDocumentOptions builder
121+
*/
122+
public Builder filename(String filename) {
123+
this.filename = filename;
124+
return this;
125+
}
126+
127+
/**
128+
* Set the fileContentType.
129+
*
130+
* @param fileContentType the fileContentType
131+
* @return the AddDocumentOptions builder
132+
*/
133+
public Builder fileContentType(String fileContentType) {
134+
this.fileContentType = fileContentType;
135+
return this;
136+
}
137+
138+
/**
139+
* Set the metadata.
140+
*
141+
* @param metadata the metadata
142+
* @return the AddDocumentOptions builder
143+
*/
144+
public Builder metadata(String metadata) {
145+
this.metadata = metadata;
146+
return this;
147+
}
148+
149+
/**
150+
* Set the xWatsonDiscoveryForce.
151+
*
152+
* @param xWatsonDiscoveryForce the xWatsonDiscoveryForce
153+
* @return the AddDocumentOptions builder
154+
*/
155+
public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) {
156+
this.xWatsonDiscoveryForce = xWatsonDiscoveryForce;
157+
return this;
158+
}
159+
160+
/**
161+
* Set the file.
162+
*
163+
* @param file the file
164+
* @return the AddDocumentOptions builder
165+
*
166+
* @throws FileNotFoundException if the file could not be found
167+
*/
168+
public Builder file(File file) throws FileNotFoundException {
169+
this.file = new FileInputStream(file);
170+
this.filename = file.getName();
171+
return this;
172+
}
173+
}
174+
175+
private AddDocumentOptions(Builder builder) {
176+
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId,
177+
"projectId cannot be empty");
178+
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId,
179+
"collectionId cannot be empty");
180+
com.ibm.cloud.sdk.core.util.Validator.isTrue((builder.file == null) || (builder.filename != null),
181+
"filename cannot be null if file is not null.");
182+
projectId = builder.projectId;
183+
collectionId = builder.collectionId;
184+
file = builder.file;
185+
filename = builder.filename;
186+
fileContentType = builder.fileContentType;
187+
metadata = builder.metadata;
188+
xWatsonDiscoveryForce = builder.xWatsonDiscoveryForce;
189+
}
190+
191+
/**
192+
* New builder.
193+
*
194+
* @return a AddDocumentOptions builder
195+
*/
196+
public Builder newBuilder() {
197+
return new Builder(this);
198+
}
199+
200+
/**
201+
* Gets the projectId.
202+
*
203+
* The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
204+
*
205+
* @return the projectId
206+
*/
207+
public String projectId() {
208+
return projectId;
209+
}
210+
211+
/**
212+
* Gets the collectionId.
213+
*
214+
* The ID of the collection.
215+
*
216+
* @return the collectionId
217+
*/
218+
public String collectionId() {
219+
return collectionId;
220+
}
221+
222+
/**
223+
* Gets the file.
224+
*
225+
* The content of the document to ingest. The maximum supported file size when adding a file to a collection is 50
226+
* megabytes, the maximum supported file size when testing a confiruration is 1 megabyte. Files larger than the
227+
* supported size are rejected.
228+
*
229+
* @return the file
230+
*/
231+
public InputStream file() {
232+
return file;
233+
}
234+
235+
/**
236+
* Gets the filename.
237+
*
238+
* The filename for file.
239+
*
240+
* @return the filename
241+
*/
242+
public String filename() {
243+
return filename;
244+
}
245+
246+
/**
247+
* Gets the fileContentType.
248+
*
249+
* The content type of file. Values for this parameter can be obtained from the HttpMediaType class.
250+
*
251+
* @return the fileContentType
252+
*/
253+
public String fileContentType() {
254+
return fileContentType;
255+
}
256+
257+
/**
258+
* Gets the metadata.
259+
*
260+
* The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected. Example: ``` {
261+
* "Creator": "Johnny Appleseed",
262+
* "Subject": "Apples"
263+
* } ```.
264+
*
265+
* @return the metadata
266+
*/
267+
public String metadata() {
268+
return metadata;
269+
}
270+
271+
/**
272+
* Gets the xWatsonDiscoveryForce.
273+
*
274+
* When `true`, the uploaded document is added to the collection even if the data for that collection is shared with
275+
* other collections.
276+
*
277+
* @return the xWatsonDiscoveryForce
278+
*/
279+
public Boolean xWatsonDiscoveryForce() {
280+
return xWatsonDiscoveryForce;
281+
}
282+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2019.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.discovery.v2.model;
14+
15+
import com.google.gson.annotations.SerializedName;
16+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
17+
18+
/**
19+
* A collection for storing documents.
20+
*/
21+
public class Collection extends GenericModel {
22+
23+
@SerializedName("collection_id")
24+
private String collectionId;
25+
private String name;
26+
27+
/**
28+
* Gets the collectionId.
29+
*
30+
* The unique identifier of the collection.
31+
*
32+
* @return the collectionId
33+
*/
34+
public String getCollectionId() {
35+
return collectionId;
36+
}
37+
38+
/**
39+
* Gets the name.
40+
*
41+
* The name of the collection.
42+
*
43+
* @return the name
44+
*/
45+
public String getName() {
46+
return name;
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2019.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.discovery.v2.model;
14+
15+
import java.util.List;
16+
17+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
18+
19+
/**
20+
* An object containing an array of autocompletion suggestions.
21+
*/
22+
public class Completions extends GenericModel {
23+
24+
private List<String> completions;
25+
26+
/**
27+
* Gets the completions.
28+
*
29+
* Array of autcomplete suggestion based on the provided prefix.
30+
*
31+
* @return the completions
32+
*/
33+
public List<String> getCompletions() {
34+
return completions;
35+
}
36+
}

0 commit comments

Comments
 (0)