Skip to content

Commit

Permalink
feat(discoveryv2): update based on api definitions
Browse files Browse the repository at this point in the history
contains some breaking model changes and new approach to handling discriminators for aggregation
types

BREAKING CHANGE: enrichmentId is now a required param for 'DocumentClassifierEnrichment' model.
'confidence' property has been removed from 'QueryResponsePassage' and 'QueryResultPassage' models.
Breaking interface changes to handling aggregation discriminators.
  • Loading branch information
jeff-arn authored and apaparazzi0329 committed Mar 15, 2023
1 parent a810f01 commit 1e2682f
Show file tree
Hide file tree
Showing 160 changed files with 1,298 additions and 839 deletions.
67 changes: 32 additions & 35 deletions discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand All @@ -12,7 +12,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.53.0-9710cac3-20220713-193508
* IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647
*/

package com.ibm.watson.discovery.v2;
Expand Down Expand Up @@ -107,17 +107,19 @@
import okhttp3.MultipartBody;

/**
* IBM Watson™ Discovery is a cognitive search and content analytics engine that you can
* add to applications to identify patterns, trends and actionable insights to drive better
* IBM Watson® Discovery is a cognitive search and content analytics engine that you can add
* to applications to identify patterns, trends and actionable insights to drive better
* decision-making. Securely unify structured and unstructured data with pre-enriched content, and
* use a simplified query language to eliminate the need for manual filtering of results.
*
* <p>API Version: 2.0 See: https://cloud.ibm.com/docs/discovery-data
*/
public class Discovery extends BaseService {

/** Default service name used when configuring the `Discovery` client. */
public static final String DEFAULT_SERVICE_NAME = "discovery";

/** Default service endpoint URL. */
public static final String DEFAULT_SERVICE_URL =
"https://api.us-south.discovery.watson.cloud.ibm.com";

Expand Down Expand Up @@ -465,12 +467,6 @@ public ServiceCall<CollectionDetails> createCollection(
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
.toJsonTree(createCollectionOptions.enrichments()));
}
if (createCollectionOptions.smartDocumentUnderstanding() != null) {
contentJson.add(
"smart_document_understanding",
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
.toJsonTree(createCollectionOptions.smartDocumentUnderstanding()));
}
builder.bodyJson(contentJson);
ResponseConverter<CollectionDetails> responseConverter =
ResponseConverterUtils.getValue(
Expand Down Expand Up @@ -597,7 +593,8 @@ public ServiceCall<Void> deleteCollection(DeleteCollectionOptions deleteCollecti
* each document and returns information for up to 10,000 documents.
*
* <p>**Note**: This method is available only from Cloud Pak for Data version 4.0.9 and later
* installed instances and from Plus and Enterprise plan IBM Cloud-managed instances.
* installed instances and from Plus and Enterprise plan IBM Cloud-managed instances. It is not
* currently available from Premium plan instances.
*
* @param listDocumentsOptions the {@link ListDocumentsOptions} containing the options for the
* call
Expand Down Expand Up @@ -653,8 +650,8 @@ public ServiceCall<ListDocumentsResponse> listDocuments(
*
* <p>Returns immediately after the system has accepted the document for processing.
*
* <p>This operation works with a file upload collection. It cannot be used to modify a collection
* that crawls an external data source.
* <p>Use this method to upload a file to the collection. You cannot use this method to crawl an
* external data source.
*
* <p>* For a list of supported file types, see the [product
* documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes).
Expand Down Expand Up @@ -731,7 +728,8 @@ public ServiceCall<DocumentAccepted> addDocument(AddDocumentOptions addDocumentO
* by crawling an external data source.
*
* <p>**Note**: This method is available only from Cloud Pak for Data version 4.0.9 and later
* installed instances and from Plus and Enterprise plan IBM Cloud-managed instances.
* installed instances and from Plus and Enterprise plan IBM Cloud-managed instances. It is not
* currently available from Premium plan instances.
*
* @param getDocumentOptions the {@link GetDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentDetails}
Expand Down Expand Up @@ -767,8 +765,8 @@ public ServiceCall<DocumentDetails> getDocument(GetDocumentOptions getDocumentOp
* <p>Replace an existing document or add a document with a specified document ID. Starts
* ingesting a document with optional metadata.
*
* <p>This operation works with a file upload collection. It cannot be used to modify a collection
* that crawls an external data source.
* <p>Use this method to upload a file to a collection. You cannot use this method to crawl an
* external data source.
*
* <p>If the document is uploaded to a collection that shares its data with another collection,
* the **X-Watson-Discovery-Force** header must be set to `true`.
Expand Down Expand Up @@ -832,15 +830,17 @@ public ServiceCall<DocumentAccepted> updateDocument(UpdateDocumentOptions update
/**
* Delete a document.
*
* <p>If the given document ID is invalid, or if the document is not found, then the a success
* response is returned (HTTP status code `200`) with the status set to 'deleted'.
*
* <p>**Note:** This operation only works on collections created to accept direct file uploads. It
* cannot be used to modify a collection that connects to an external source such as Microsoft
* SharePoint.
* <p>Deletes the document with the document ID that you specify from the collection. Removes
* uploaded documents from the collection permanently. If you delete a document that was added by
* crawling an external data source, the document will be added again with the next scheduled
* crawl of the data source. The delete function removes the document from the collection, not
* from the external data source.
*
* <p>**Note:** Segments of an uploaded document cannot be deleted individually. Delete all
* segments by deleting using the `parent_document_id` of a segment result.
* <p>**Note:** Files such as CSV or JSON files generate subdocuments when they are added to a
* collection. If you delete a subdocument, and then repeat the action that created it, the
* deleted document is added back in to your collection. To remove subdocuments that are generated
* by an uploaded file, delete the original document instead. You can get the document ID of the
* original document from the `parent_document_id` of the subdocument result.
*
* @param deleteDocumentOptions the {@link DeleteDocumentOptions} containing the options for the
* call
Expand Down Expand Up @@ -880,12 +880,11 @@ public ServiceCall<DeleteDocumentResponse> deleteDocument(
*
* <p>Search your data by submitting queries that are written in natural language or formatted in
* the Discovery Query Language. For more information, see the [Discovery
* documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-query-concepts).
* The default query parameters differ by project type. For more information about the project
* default settings, see the [Discovery
* documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-query-defaults).
* See [the Projects API documentation](#create-project) for details about how to set custom
* default query settings.
* documentation](/docs/discovery-data?topic=discovery-data-query-concepts). The default query
* parameters differ by project type. For more information about the project default settings, see
* the [Discovery documentation](/docs/discovery-data?topic=discovery-data-query-defaults). See
* [the Projects API documentation](#create-project) for details about how to set custom default
* query settings.
*
* <p>The length of the UTF-8 encoding of the POST body cannot exceed 10,000 bytes, which is
* roughly equivalent to 10,000 characters in English.
Expand Down Expand Up @@ -1163,10 +1162,8 @@ public ServiceCall<StopWordList> getStopwordList(GetStopwordListOptions getStopw
* indexing time and at query time. A custom stop words list that you add is used at query time
* only.
*
* <p>The custom stop words list replaces the default stop words list. Therefore, if you want to
* keep the stop words that were used when the collection was indexed, get the default stop words
* list for the language of the collection first and edit it to create your custom list. For
* information about the default stop words lists per language, see [the product
* <p>The custom stop words list augments the default stop words list; you cannot remove stop
* words. For information about the default stop words lists per language, see [the product
* documentation](/docs/discovery-data?topic=discovery-data-stopwords).
*
* @param createStopwordListOptions the {@link CreateStopwordListOptions} containing the options
Expand Down Expand Up @@ -2260,7 +2257,7 @@ public ServiceCall<AnalyzedDocument> analyzeDocument(
* <p>You associate a customer ID with data by passing the **X-Watson-Metadata** header with a
* request that passes data. For more information about personal data and customer IDs, see
* [Information
* security](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-information-security#information-security).
* security](/docs/discovery-data?topic=discovery-data-information-security#information-security).
*
* <p>**Note:** This method is only supported on IBM Cloud instances of Discovery.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand Down Expand Up @@ -39,6 +39,11 @@ public static class Builder {
private String metadata;
private Boolean xWatsonDiscoveryForce;

/**
* Instantiates a new Builder from an existing AddDocumentOptions instance.
*
* @param addDocumentOptions the instance to initialize the Builder with
*/
private Builder(AddDocumentOptions addDocumentOptions) {
this.projectId = addDocumentOptions.projectId;
this.collectionId = addDocumentOptions.collectionId;
Expand Down Expand Up @@ -218,7 +223,7 @@ public String collectionId() {
*
* <p>When adding a document, the content of the document to ingest. For maximum supported file
* size limits, see [the
* documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-collections#collections-doc-limits).
* documentation](/docs/discovery-data?topic=discovery-data-collections#collections-doc-limits).
*
* <p>When analyzing a document, the content of the document to analyze but not ingest. Only the
* `application/json` content type is supported currently. For maximum supported file size limits,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020, 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand Down Expand Up @@ -37,6 +37,11 @@ public static class Builder {
private String fileContentType;
private String metadata;

/**
* Instantiates a new Builder from an existing AnalyzeDocumentOptions instance.
*
* @param analyzeDocumentOptions the instance to initialize the Builder with
*/
private Builder(AnalyzeDocumentOptions analyzeDocumentOptions) {
this.projectId = analyzeDocumentOptions.projectId;
this.collectionId = analyzeDocumentOptions.collectionId;
Expand Down Expand Up @@ -203,7 +208,7 @@ public String collectionId() {
*
* <p>When adding a document, the content of the document to ingest. For maximum supported file
* size limits, see [the
* documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-collections#collections-doc-limits).
* documentation](/docs/discovery-data?topic=discovery-data-collections#collections-doc-limits).
*
* <p>When analyzing a document, the content of the document to analyze but not ingest. Only the
* `application/json` content type is supported currently. For maximum supported file size limits,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020, 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand All @@ -24,6 +24,8 @@ public class AnalyzedDocument extends GenericModel {
protected List<Notice> notices;
protected AnalyzedResult result;

protected AnalyzedDocument() {}

/**
* Gets the notices.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand All @@ -23,6 +23,11 @@ public class ClassifierFederatedModel extends GenericModel {
public static class Builder {
private String field;

/**
* Instantiates a new Builder from an existing ClassifierFederatedModel instance.
*
* @param classifierFederatedModel the instance to initialize the Builder with
*/
private Builder(ClassifierFederatedModel classifierFederatedModel) {
this.field = classifierFederatedModel.field;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand Down Expand Up @@ -28,6 +28,8 @@ public class ClassifierModelEvaluation extends GenericModel {
@SerializedName("per_class")
protected List<PerClassModelEvaluation> perClass;

protected ClassifierModelEvaluation() {}

/**
* Gets the microAverage.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand All @@ -23,6 +23,8 @@ public class Collection extends GenericModel {

protected String name;

protected Collection() {}

/**
* Gets the collectionId.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020, 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand Down Expand Up @@ -39,14 +39,17 @@ public static class Builder {
private String description;
private String language;
private List<CollectionEnrichment> enrichments;
private CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding;

/**
* Instantiates a new Builder from an existing CollectionDetails instance.
*
* @param collectionDetails the instance to initialize the Builder with
*/
private Builder(CollectionDetails collectionDetails) {
this.name = collectionDetails.name;
this.description = collectionDetails.description;
this.language = collectionDetails.language;
this.enrichments = collectionDetails.enrichments;
this.smartDocumentUnderstanding = collectionDetails.smartDocumentUnderstanding;
}

/** Instantiates a new builder. */
Expand Down Expand Up @@ -128,18 +131,6 @@ public Builder enrichments(List<CollectionEnrichment> enrichments) {
this.enrichments = enrichments;
return this;
}

/**
* Set the smartDocumentUnderstanding.
*
* @param smartDocumentUnderstanding the smartDocumentUnderstanding
* @return the CollectionDetails builder
*/
public Builder smartDocumentUnderstanding(
CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding) {
this.smartDocumentUnderstanding = smartDocumentUnderstanding;
return this;
}
}

protected CollectionDetails() {}
Expand All @@ -150,7 +141,6 @@ protected CollectionDetails(Builder builder) {
description = builder.description;
language = builder.language;
enrichments = builder.enrichments;
smartDocumentUnderstanding = builder.smartDocumentUnderstanding;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand Down Expand Up @@ -51,6 +51,13 @@ public static class Builder {
private Boolean enabled;
private String model;

/**
* Instantiates a new Builder from an existing CollectionDetailsSmartDocumentUnderstanding
* instance.
*
* @param collectionDetailsSmartDocumentUnderstanding the instance to initialize the Builder
* with
*/
private Builder(
CollectionDetailsSmartDocumentUnderstanding collectionDetailsSmartDocumentUnderstanding) {
this.enabled = collectionDetailsSmartDocumentUnderstanding.enabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020, 2022.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand Down Expand Up @@ -30,6 +30,11 @@ public static class Builder {
private String enrichmentId;
private List<String> fields;

/**
* Instantiates a new Builder from an existing CollectionEnrichment instance.
*
* @param collectionEnrichment the instance to initialize the Builder with
*/
private Builder(CollectionEnrichment collectionEnrichment) {
this.enrichmentId = collectionEnrichment.enrichmentId;
this.fields = collectionEnrichment.fields;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2021.
* (C) Copyright IBM Corp. 2023.
*
* 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
Expand All @@ -20,6 +20,8 @@ public class Completions extends GenericModel {

protected List<String> completions;

protected Completions() {}

/**
* Gets the completions.
*
Expand Down

0 comments on commit 1e2682f

Please sign in to comment.