-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Discovery v2): Add initial generation of service
- Loading branch information
Showing
73 changed files
with
8,101 additions
and
0 deletions.
There are no files selected for viewing
672 changes: 672 additions & 0 deletions
672
discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java
Large diffs are not rendered by default.
Oops, something went wrong.
282 changes: 282 additions & 0 deletions
282
discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2019. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.ibm.watson.discovery.v2.model; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.InputStream; | ||
|
||
import com.ibm.cloud.sdk.core.service.model.GenericModel; | ||
|
||
/** | ||
* The addDocument options. | ||
*/ | ||
public class AddDocumentOptions extends GenericModel { | ||
|
||
private String projectId; | ||
private String collectionId; | ||
private InputStream file; | ||
private String filename; | ||
private String fileContentType; | ||
private String metadata; | ||
private Boolean xWatsonDiscoveryForce; | ||
|
||
/** | ||
* Builder. | ||
*/ | ||
public static class Builder { | ||
private String projectId; | ||
private String collectionId; | ||
private InputStream file; | ||
private String filename; | ||
private String fileContentType; | ||
private String metadata; | ||
private Boolean xWatsonDiscoveryForce; | ||
|
||
private Builder(AddDocumentOptions addDocumentOptions) { | ||
this.projectId = addDocumentOptions.projectId; | ||
this.collectionId = addDocumentOptions.collectionId; | ||
this.file = addDocumentOptions.file; | ||
this.filename = addDocumentOptions.filename; | ||
this.fileContentType = addDocumentOptions.fileContentType; | ||
this.metadata = addDocumentOptions.metadata; | ||
this.xWatsonDiscoveryForce = addDocumentOptions.xWatsonDiscoveryForce; | ||
} | ||
|
||
/** | ||
* Instantiates a new builder. | ||
*/ | ||
public Builder() { | ||
} | ||
|
||
/** | ||
* Instantiates a new builder with required properties. | ||
* | ||
* @param projectId the projectId | ||
* @param collectionId the collectionId | ||
*/ | ||
public Builder(String projectId, String collectionId) { | ||
this.projectId = projectId; | ||
this.collectionId = collectionId; | ||
} | ||
|
||
/** | ||
* Builds a AddDocumentOptions. | ||
* | ||
* @return the addDocumentOptions | ||
*/ | ||
public AddDocumentOptions build() { | ||
return new AddDocumentOptions(this); | ||
} | ||
|
||
/** | ||
* Set the projectId. | ||
* | ||
* @param projectId the projectId | ||
* @return the AddDocumentOptions builder | ||
*/ | ||
public Builder projectId(String projectId) { | ||
this.projectId = projectId; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the collectionId. | ||
* | ||
* @param collectionId the collectionId | ||
* @return the AddDocumentOptions builder | ||
*/ | ||
public Builder collectionId(String collectionId) { | ||
this.collectionId = collectionId; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the file. | ||
* | ||
* @param file the file | ||
* @return the AddDocumentOptions builder | ||
*/ | ||
public Builder file(InputStream file) { | ||
this.file = file; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the filename. | ||
* | ||
* @param filename the filename | ||
* @return the AddDocumentOptions builder | ||
*/ | ||
public Builder filename(String filename) { | ||
this.filename = filename; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the fileContentType. | ||
* | ||
* @param fileContentType the fileContentType | ||
* @return the AddDocumentOptions builder | ||
*/ | ||
public Builder fileContentType(String fileContentType) { | ||
this.fileContentType = fileContentType; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the metadata. | ||
* | ||
* @param metadata the metadata | ||
* @return the AddDocumentOptions builder | ||
*/ | ||
public Builder metadata(String metadata) { | ||
this.metadata = metadata; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the xWatsonDiscoveryForce. | ||
* | ||
* @param xWatsonDiscoveryForce the xWatsonDiscoveryForce | ||
* @return the AddDocumentOptions builder | ||
*/ | ||
public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) { | ||
this.xWatsonDiscoveryForce = xWatsonDiscoveryForce; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the file. | ||
* | ||
* @param file the file | ||
* @return the AddDocumentOptions builder | ||
* | ||
* @throws FileNotFoundException if the file could not be found | ||
*/ | ||
public Builder file(File file) throws FileNotFoundException { | ||
this.file = new FileInputStream(file); | ||
this.filename = file.getName(); | ||
return this; | ||
} | ||
} | ||
|
||
private AddDocumentOptions(Builder builder) { | ||
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, | ||
"projectId cannot be empty"); | ||
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, | ||
"collectionId cannot be empty"); | ||
com.ibm.cloud.sdk.core.util.Validator.isTrue((builder.file == null) || (builder.filename != null), | ||
"filename cannot be null if file is not null."); | ||
projectId = builder.projectId; | ||
collectionId = builder.collectionId; | ||
file = builder.file; | ||
filename = builder.filename; | ||
fileContentType = builder.fileContentType; | ||
metadata = builder.metadata; | ||
xWatsonDiscoveryForce = builder.xWatsonDiscoveryForce; | ||
} | ||
|
||
/** | ||
* New builder. | ||
* | ||
* @return a AddDocumentOptions builder | ||
*/ | ||
public Builder newBuilder() { | ||
return new Builder(this); | ||
} | ||
|
||
/** | ||
* Gets the projectId. | ||
* | ||
* The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. | ||
* | ||
* @return the projectId | ||
*/ | ||
public String projectId() { | ||
return projectId; | ||
} | ||
|
||
/** | ||
* Gets the collectionId. | ||
* | ||
* The ID of the collection. | ||
* | ||
* @return the collectionId | ||
*/ | ||
public String collectionId() { | ||
return collectionId; | ||
} | ||
|
||
/** | ||
* Gets the file. | ||
* | ||
* The content of the document to ingest. The maximum supported file size when adding a file to a collection is 50 | ||
* megabytes, the maximum supported file size when testing a confiruration is 1 megabyte. Files larger than the | ||
* supported size are rejected. | ||
* | ||
* @return the file | ||
*/ | ||
public InputStream file() { | ||
return file; | ||
} | ||
|
||
/** | ||
* Gets the filename. | ||
* | ||
* The filename for file. | ||
* | ||
* @return the filename | ||
*/ | ||
public String filename() { | ||
return filename; | ||
} | ||
|
||
/** | ||
* Gets the fileContentType. | ||
* | ||
* The content type of file. Values for this parameter can be obtained from the HttpMediaType class. | ||
* | ||
* @return the fileContentType | ||
*/ | ||
public String fileContentType() { | ||
return fileContentType; | ||
} | ||
|
||
/** | ||
* Gets the metadata. | ||
* | ||
* The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected. Example: ``` { | ||
* "Creator": "Johnny Appleseed", | ||
* "Subject": "Apples" | ||
* } ```. | ||
* | ||
* @return the metadata | ||
*/ | ||
public String metadata() { | ||
return metadata; | ||
} | ||
|
||
/** | ||
* Gets the xWatsonDiscoveryForce. | ||
* | ||
* When `true`, the uploaded document is added to the collection even if the data for that collection is shared with | ||
* other collections. | ||
* | ||
* @return the xWatsonDiscoveryForce | ||
*/ | ||
public Boolean xWatsonDiscoveryForce() { | ||
return xWatsonDiscoveryForce; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2019. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.ibm.watson.discovery.v2.model; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import com.ibm.cloud.sdk.core.service.model.GenericModel; | ||
|
||
/** | ||
* A collection for storing documents. | ||
*/ | ||
public class Collection extends GenericModel { | ||
|
||
@SerializedName("collection_id") | ||
private String collectionId; | ||
private String name; | ||
|
||
/** | ||
* Gets the collectionId. | ||
* | ||
* The unique identifier of the collection. | ||
* | ||
* @return the collectionId | ||
*/ | ||
public String getCollectionId() { | ||
return collectionId; | ||
} | ||
|
||
/** | ||
* Gets the name. | ||
* | ||
* The name of the collection. | ||
* | ||
* @return the name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2019. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.ibm.watson.discovery.v2.model; | ||
|
||
import java.util.List; | ||
|
||
import com.ibm.cloud.sdk.core.service.model.GenericModel; | ||
|
||
/** | ||
* An object containing an array of autocompletion suggestions. | ||
*/ | ||
public class Completions extends GenericModel { | ||
|
||
private List<String> completions; | ||
|
||
/** | ||
* Gets the completions. | ||
* | ||
* Array of autcomplete suggestion based on the provided prefix. | ||
* | ||
* @return the completions | ||
*/ | ||
public List<String> getCompletions() { | ||
return completions; | ||
} | ||
} |
Oops, something went wrong.