Skip to content

Commit 78d93b7

Browse files
feat(discov2): new EnrichmentOptions parameters
1 parent a8399c1 commit 78d93b7

File tree

8 files changed

+423
-35
lines changed

8 files changed

+423
-35
lines changed

discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2020, 2023.
2+
* (C) Copyright IBM Corp. 2024.
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
@@ -43,6 +43,14 @@ public class CreateEnrichment extends GenericModel {
4343
*
4444
* <p>* `watson_knowledge_studio_model`: Creates an enrichment from a Watson Knowledge Studio
4545
* machine learning model that is defined in a ZIP file.
46+
*
47+
* <p>* `webhook`: Connects to an external enrichment application by using a webhook. The feature
48+
* is available from IBM Cloud-managed instances only. The external enrichment feature is beta
49+
* functionality. Beta features are not supported by the SDKs.
50+
*
51+
* <p>* `sentence_classifier`: Use sentence classifier to classify sentences in your documents.
52+
* This feature is available in IBM Cloud-managed instances only. The sentence classifier feature
53+
* is beta functionality. Beta features are not supported by the SDKs.
4654
*/
4755
public interface Type {
4856
/** classifier. */
@@ -57,6 +65,10 @@ public interface Type {
5765
String RULE_BASED = "rule_based";
5866
/** watson_knowledge_studio_model. */
5967
String WATSON_KNOWLEDGE_STUDIO_MODEL = "watson_knowledge_studio_model";
68+
/** webhook. */
69+
String WEBHOOK = "webhook";
70+
/** sentence_classifier. */
71+
String SENTENCE_CLASSIFIER = "sentence_classifier";
6072
}
6173

6274
protected String name;
@@ -209,6 +221,14 @@ public String description() {
209221
* <p>* `watson_knowledge_studio_model`: Creates an enrichment from a Watson Knowledge Studio
210222
* machine learning model that is defined in a ZIP file.
211223
*
224+
* <p>* `webhook`: Connects to an external enrichment application by using a webhook. The feature
225+
* is available from IBM Cloud-managed instances only. The external enrichment feature is beta
226+
* functionality. Beta features are not supported by the SDKs.
227+
*
228+
* <p>* `sentence_classifier`: Use sentence classifier to classify sentences in your documents.
229+
* This feature is available in IBM Cloud-managed instances only. The sentence classifier feature
230+
* is beta functionality. Beta features are not supported by the SDKs.
231+
*
212232
* @return the type
213233
*/
214234
public String type() {

discovery/src/main/java/com/ibm/watson/discovery/v2/model/Enrichment.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2020, 2023.
2+
* (C) Copyright IBM Corp. 2024.
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
@@ -38,6 +38,10 @@ public interface Type {
3838
String WATSON_KNOWLEDGE_STUDIO_MODEL = "watson_knowledge_studio_model";
3939
/** classifier. */
4040
String CLASSIFIER = "classifier";
41+
/** webhook. */
42+
String WEBHOOK = "webhook";
43+
/** sentence_classifier. */
44+
String SENTENCE_CLASSIFIER = "sentence_classifier";
4145
}
4246

4347
@SerializedName("enrichment_id")

discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java

+146-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2020, 2023.
2+
* (C) Copyright IBM Corp. 2024.
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
@@ -46,6 +46,14 @@ public class EnrichmentOptions extends GenericModel {
4646
@SerializedName("top_k")
4747
protected Long topK;
4848

49+
protected String url;
50+
protected String version;
51+
protected String secret;
52+
protected WebhookHeader headers;
53+
54+
@SerializedName("location_encoding")
55+
protected String locationEncoding;
56+
4957
/** Builder. */
5058
public static class Builder {
5159
private List<String> languages;
@@ -56,6 +64,11 @@ public static class Builder {
5664
private String modelId;
5765
private Double confidenceThreshold;
5866
private Long topK;
67+
private String url;
68+
private String version;
69+
private String secret;
70+
private WebhookHeader headers;
71+
private String locationEncoding;
5972

6073
/**
6174
* Instantiates a new Builder from an existing EnrichmentOptions instance.
@@ -71,6 +84,11 @@ private Builder(EnrichmentOptions enrichmentOptions) {
7184
this.modelId = enrichmentOptions.modelId;
7285
this.confidenceThreshold = enrichmentOptions.confidenceThreshold;
7386
this.topK = enrichmentOptions.topK;
87+
this.url = enrichmentOptions.url;
88+
this.version = enrichmentOptions.version;
89+
this.secret = enrichmentOptions.secret;
90+
this.headers = enrichmentOptions.headers;
91+
this.locationEncoding = enrichmentOptions.locationEncoding;
7492
}
7593

7694
/** Instantiates a new builder. */
@@ -86,9 +104,9 @@ public EnrichmentOptions build() {
86104
}
87105

88106
/**
89-
* Adds an languages to languages.
107+
* Adds a new element to languages.
90108
*
91-
* @param languages the new languages
109+
* @param languages the new element to be added
92110
* @return the EnrichmentOptions builder
93111
*/
94112
public Builder addLanguages(String languages) {
@@ -187,6 +205,61 @@ public Builder topK(long topK) {
187205
this.topK = topK;
188206
return this;
189207
}
208+
209+
/**
210+
* Set the url.
211+
*
212+
* @param url the url
213+
* @return the EnrichmentOptions builder
214+
*/
215+
public Builder url(String url) {
216+
this.url = url;
217+
return this;
218+
}
219+
220+
/**
221+
* Set the version.
222+
*
223+
* @param version the version
224+
* @return the EnrichmentOptions builder
225+
*/
226+
public Builder version(String version) {
227+
this.version = version;
228+
return this;
229+
}
230+
231+
/**
232+
* Set the secret.
233+
*
234+
* @param secret the secret
235+
* @return the EnrichmentOptions builder
236+
*/
237+
public Builder secret(String secret) {
238+
this.secret = secret;
239+
return this;
240+
}
241+
242+
/**
243+
* Set the headers.
244+
*
245+
* @param headers the headers
246+
* @return the EnrichmentOptions builder
247+
*/
248+
public Builder headers(WebhookHeader headers) {
249+
this.headers = headers;
250+
return this;
251+
}
252+
253+
/**
254+
* Set the locationEncoding.
255+
*
256+
* @param locationEncoding the locationEncoding
257+
* @return the EnrichmentOptions builder
258+
*/
259+
public Builder locationEncoding(String locationEncoding) {
260+
this.locationEncoding = locationEncoding;
261+
return this;
262+
}
190263
}
191264

192265
protected EnrichmentOptions() {}
@@ -200,6 +273,11 @@ protected EnrichmentOptions(Builder builder) {
200273
modelId = builder.modelId;
201274
confidenceThreshold = builder.confidenceThreshold;
202275
topK = builder.topK;
276+
url = builder.url;
277+
version = builder.version;
278+
secret = builder.secret;
279+
headers = builder.headers;
280+
locationEncoding = builder.locationEncoding;
203281
}
204282

205283
/**
@@ -312,4 +390,69 @@ public Double confidenceThreshold() {
312390
public Long topK() {
313391
return topK;
314392
}
393+
394+
/**
395+
* Gets the url.
396+
*
397+
* <p>A URL that uses the SSL protocol (begins with https) for the webhook. Required when type is
398+
* `webhook`. Not valid when creating any other type of enrichment.
399+
*
400+
* @return the url
401+
*/
402+
public String url() {
403+
return url;
404+
}
405+
406+
/**
407+
* Gets the version.
408+
*
409+
* <p>The Discovery API version that allows to distinguish the schema. The version is specified in
410+
* the `yyyy-mm-dd` format. Optional when `type` is `webhook`. Not valid when creating any other
411+
* type of enrichment.
412+
*
413+
* @return the version
414+
*/
415+
public String version() {
416+
return version;
417+
}
418+
419+
/**
420+
* Gets the secret.
421+
*
422+
* <p>A private key can be included in the request to authenticate with the external service. The
423+
* maximum length is 1,024 characters. Optional when `type` is `webhook`. Not valid when creating
424+
* any other type of enrichment.
425+
*
426+
* @return the secret
427+
*/
428+
public String secret() {
429+
return secret;
430+
}
431+
432+
/**
433+
* Gets the headers.
434+
*
435+
* <p>An array of headers to pass with the HTTP request. Optional when `type` is `webhook`. Not
436+
* valid when creating any other type of enrichment.
437+
*
438+
* @return the headers
439+
*/
440+
public WebhookHeader headers() {
441+
return headers;
442+
}
443+
444+
/**
445+
* Gets the locationEncoding.
446+
*
447+
* <p>Discovery calculates offsets of the text's location with this encoding type in documents.
448+
* Use the same location encoding type in both Discovery and external enrichment for a document.
449+
*
450+
* <p>These encoding types are supported: `utf-8`, `utf-16`, and `utf-32`. Optional when `type` is
451+
* `webhook`. Not valid when creating any other type of enrichment.
452+
*
453+
* @return the locationEncoding
454+
*/
455+
public String locationEncoding() {
456+
return locationEncoding;
457+
}
315458
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2024.
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.ibm.cloud.sdk.core.service.model.GenericModel;
16+
17+
/**
18+
* An array of headers to pass with the HTTP request. Optional when `type` is `webhook`. Not valid
19+
* when creating any other type of enrichment.
20+
*/
21+
public class WebhookHeader extends GenericModel {
22+
23+
protected String name;
24+
protected String value;
25+
26+
/** Builder. */
27+
public static class Builder {
28+
private String name;
29+
private String value;
30+
31+
/**
32+
* Instantiates a new Builder from an existing WebhookHeader instance.
33+
*
34+
* @param webhookHeader the instance to initialize the Builder with
35+
*/
36+
private Builder(WebhookHeader webhookHeader) {
37+
this.name = webhookHeader.name;
38+
this.value = webhookHeader.value;
39+
}
40+
41+
/** Instantiates a new builder. */
42+
public Builder() {}
43+
44+
/**
45+
* Instantiates a new builder with required properties.
46+
*
47+
* @param name the name
48+
* @param value the value
49+
*/
50+
public Builder(String name, String value) {
51+
this.name = name;
52+
this.value = value;
53+
}
54+
55+
/**
56+
* Builds a WebhookHeader.
57+
*
58+
* @return the new WebhookHeader instance
59+
*/
60+
public WebhookHeader build() {
61+
return new WebhookHeader(this);
62+
}
63+
64+
/**
65+
* Set the name.
66+
*
67+
* @param name the name
68+
* @return the WebhookHeader builder
69+
*/
70+
public Builder name(String name) {
71+
this.name = name;
72+
return this;
73+
}
74+
75+
/**
76+
* Set the value.
77+
*
78+
* @param value the value
79+
* @return the WebhookHeader builder
80+
*/
81+
public Builder value(String value) {
82+
this.value = value;
83+
return this;
84+
}
85+
}
86+
87+
protected WebhookHeader() {}
88+
89+
protected WebhookHeader(Builder builder) {
90+
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null");
91+
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null");
92+
name = builder.name;
93+
value = builder.value;
94+
}
95+
96+
/**
97+
* New builder.
98+
*
99+
* @return a WebhookHeader builder
100+
*/
101+
public Builder newBuilder() {
102+
return new Builder(this);
103+
}
104+
105+
/**
106+
* Gets the name.
107+
*
108+
* <p>The name of an HTTP header.
109+
*
110+
* @return the name
111+
*/
112+
public String name() {
113+
return name;
114+
}
115+
116+
/**
117+
* Gets the value.
118+
*
119+
* <p>The value of an HTTP header.
120+
*
121+
* @return the value
122+
*/
123+
public String value() {
124+
return value;
125+
}
126+
}

0 commit comments

Comments
 (0)